java测试cpu时间 如何做,得到执行一个方法的cpu时间 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public static void main(String[] args) { long m,n; System.out.println(m=System.currentTimeMillis()); int a=0; for(int i = 1;i<10000000;i++){ a=a+i; } System.out.println(n=System.currentTimeMillis()); System.out.println(n-m); } 在方法执行之前和之后分别调用一次System.currentTimeMillis()不行吗?更精确的(比如精确到微秒)可能得用到JNI了吧。 这样就可以获取到大概的时间,整个程序运行所需要的时间,但是这个不精确,问题涉及到线程的休眠和阻塞问题和其它很多进程的调度问题。所以一般来说,cpu运行时间要比程序执行时间短很多。 谢谢 所以想求助cpu时间如何取得 谁能帮助我啊 ativesource.cppD:\tools\vc66\MSDev98\MyProjects\native\nativesource.cpp(11) : error C2065: 's_currentProcess' : undeclared identifierD:\tools\vc66\MSDev98\MyProjects\native\nativesource.cpp(11) : error C2440: '=' : cannot convert from 'void *' to 'int' This conversion requires a reinterpret_cast, a C-style cast or function-style castD:\tools\vc66\MSDev98\MyProjects\native\nativesource.cpp(14) : error C2065: 's_numberOfProcessors' : undeclared identifierD:\tools\vc66\MSDev98\MyProjects\native\nativesource.cpp(30) : error C2065: 'fileTimeToInt64' : undeclared identifierError executing cl.exe.家那个头以后错误减少了 但是还是有 不知道怎么调试 ,链接中的例子 我不太会弄 那个可以测试cpu时间吗 我想测试web系统性能。 不要系统时间想要测试cpu时间 测试web性能 有什么好办法吗 http://www.99inf.net/SoftwareDev/Java/54523.htm谁能把链接中的例子搞通啊 我有一个form表单,现在写了一个servlet.java要怎么配置啊 求2个系列的经典的java教程 spring配置问题 用myeclipse编辑jsp时,提示unkown tag(!) jsp 中不能使用<a href="#c"> <a name="c"> 进就有分!!!(新年发钱,我散分!!哈哈高兴) jsp 连接access数据库问题 JSP+JAVABEAN 急~~~ 我想要将“\”转换成别的字符,怎么做? Applet如何读取session中的数据 请问java 字符串换行连接符是哪个? jsp连接数据库出错 servlet问题连接数据库的问题
long m,n;
System.out.println(m=System.currentTimeMillis());
int a=0;
for(int i = 1;i<10000000;i++){
a=a+i;
}
System.out.println(n=System.currentTimeMillis());
System.out.println(n-m);
}
更精确的(比如精确到微秒)可能得用到JNI了吧。
这样就可以获取到大概的时间,整个程序运行所需要的时间,但是这个不精确,问题涉及到线程的休眠和阻塞问题和其它很多进程的调度问题。
所以一般来说,cpu运行时间要比程序执行时间短很多。
D:\tools\vc66\MSDev98\MyProjects\native\nativesource.cpp(11) : error C2065: 's_currentProcess' : undeclared identifier
D:\tools\vc66\MSDev98\MyProjects\native\nativesource.cpp(11) : error C2440: '=' : cannot convert from 'void *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
D:\tools\vc66\MSDev98\MyProjects\native\nativesource.cpp(14) : error C2065: 's_numberOfProcessors' : undeclared identifier
D:\tools\vc66\MSDev98\MyProjects\native\nativesource.cpp(30) : error C2065: 'fileTimeToInt64' : undeclared identifier
Error executing cl.exe.
家那个头以后错误减少了
但是还是有 不知道怎么调试 ,链接中的例子 我不太会弄 那个可以测试cpu时间吗 我想测试web系统性能。
想要测试cpu时间 测试web性能 有什么好办法吗
谁能把链接中的例子搞通啊