Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see call tree profiling in JMH?

I want to profile JMH tests and look at a call tree like in the VisualVM. But when I use the StackProfiler, it gives me native methods like that, which totally useless in my case.

....[Thread state distributions]....................................................................
 59,9%         TIMED_WAITING
 23,0%         WAITING
 17,0%         RUNNABLE

....[Thread state: TIMED_WAITING]...................................................................
 47,3%  78,9% sun.misc.Unsafe.park
  8,3%  13,8% java.lang.Thread.sleep
  4,4%   7,3% java.lang.Object.wait

....[Thread state: WAITING].........................................................................
 21,9%  95,1% sun.misc.Unsafe.park
  1,1%   4,9% java.lang.Object.wait

....[Thread state: RUNNABLE]........................................................................
 13,5%  79,0% sun.nio.ch.EPollArrayWrapper.epollWait
  2,0%  11,5% java.net.SocketInputStream.socketRead0
  1,0%   5,7% java.net.PlainSocketImpl.socketAccept
like image 606
Александр Меньшиков Avatar asked Mar 09 '23 22:03

Александр Меньшиков


1 Answers

JMH's stack profiler is a rather simplistic implementation. Why not use the full-fledged profiler -- e.g. VisualVM you mentioned -- if you need something more? Alternatively, see -prof stack:help:

$ java -jar jmh-samples/target/benchmarks.jar -prof stack:help
Usage: -prof <profiler-name>:opt1=value1,value2;opt2=value3

Options accepted by org.openjdk.jmh.profile.StackProfiler:

  lines=<int>     Number of stack lines to save in each stack trace.
                  Larger values provide more insight into who is calling
                  the top stack method, as the expense of more stack
                  trace shapes to collect. (default: [1])
like image 182
Aleksey Shipilev Avatar answered Mar 11 '23 13:03

Aleksey Shipilev