use*_*343 7 java cpu instruction-set
我想知道我的java代码消耗了多少指令来执行.我正在寻找一个开始指令计数的api,最后应该返回最终的指令总数
例如:
public static void main()
{
int a=0;
int b=0;
int c=0;
startCountinst();
if(a==b)
{
c++;
}
int n = stopCountinst();
}
Run Code Online (Sandbox Code Playgroud)
最后,n应表示调用后执行的指令总数startCountinst().在java中可以计算指令吗?
我喜欢这个问题。对于衡量性能可能有用。但并非每条指令都需要相同的时间。所以你最好看看分析你的代码。
JProfiler 相当流行:
https://www.ej-technologies.com/products/jprofiler/overview.html
并且有几种免费的替代方案可用。只需 Google for java profiler 即可查看。有大量可用信息。
| 归档时间: |
|
| 查看次数: |
2910 次 |
| 最近记录: |