dfa*_*dfa 21 java performance timing
我经常在System.nanoTime()对中包装代码以便对其进行计时.就像是:
long start = System.nanoTime();
methodToBeTimed();
long elapsedTime = System.nanoTime() - start;
Run Code Online (Sandbox Code Playgroud)
有什么好的计时库可以解决这个问题吗?还将接受自行开发的代码.
NB
分析器不是解决方案,因为我想在单元测试中强制执行一些时间限制,所以我想以编程方式对方法进行计时.
不是你的问题的直接答案,但我也经常使用这个技巧来计算我的代码,并编写了以下简单的Eclipse - > Surround With模板:
long startTime = System.currentTimeMillis();
${line_selection}${cursor}
long totalTime = System.currentTimeMillis() - startTime;
System.out.println("Total time = " + totalTime);
System.out.println();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15369 次 |
| 最近记录: |