简体   繁体   English

如何对一个Java方法的内部实现进行基准测试?

[英]How to benchmark internal implementation of one java method?

I have been using jmh for few months, and it is a great framework, that gives out the measurement of different java methods. 我已经使用jmh几个月了,这是一个很棒的框架,它给出了不同java方法的度量。

Now what I would like to know is within that same method, that I have benchmarked with jmh , I would like for x ns/op , to know how much of this x was spent in native calls, and how much was spent in scheduling, etc... 现在,我想知道的是在同一方法中,我已经用jmh进行了基准测试,我希望获得x ns/op ,以了解这x花费了多少本机调用,以及多少花费在调度上,等等...

I am not sure if there is a tool to do that. 我不确定是否有工具可以做到这一点。

Maybe following link is some what closer http://docs.oracle.com/javase/7/docs/technotes/samples/hprof.html you can find help info with command java -agentlib:hprof=help . 也许下面的链接更接近http://docs.oracle.com/javase/7/docs/technotes/samples/hprof.html,您可以使用命令java -agentlib:hprof = help查找帮助信息。 But still it wont give you the time spent in scheduling, switching etc. 但是它仍然不会给您花费时间安排,切换等。

What you are likely looking for is a profiler to give you the performance. 您可能需要的是探查器,以提高性能。 I know on tool offhand that would be able to accommodate your request, however I am certain there is a number of Java profilers out there that could work for you just as well. 我知道临时工具可以满足您的要求,但是我敢肯定有很多Java探查器也可以为您服务。

https://code.google.com/a/eclipselabs.org/p/jvmmonitor/ https://code.google.com/a/eclipselabs.org/p/jvmmonitor/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM