Isolating setup of StackWalker test call stack in JMH?

Brent Christian brent.christian at oracle.com
Fri Aug 25 23:43:52 UTC 2023


Thanks for the response, Sergey.

On 8/15/23 9:52 PM, Sergey Kuksenko wrote:
 > Invoking nanoTime twice per operation, you will get large nanoTime overhead.
 > https://shipilev.net/blog/2014/nanotrusting-nanotime/

That's very interesting.

 > May I ask you - why do you need to move stack construction into "setup"?

I originally wanted StackWalkBench.getCallerClass() to be able to confirm that 
StackWalker.getCallerClass() performs the same, regardless of call stack depth. The benchmark first 
makes method calls to create a call stack depth of `depth` (which I don't want to be part of the 
measurement) before calling getCallerClass().

At this point, StackWalker is mature enough that we're confident that getCallerClass() 
behaves/performs as expected regardless of call stack depth. So in PR 15370[1], the benchmark will 
simplify the benchmark to just call getCallerClass(), without adding to the call stack.

Thanks,
-Brent

1. https://github.com/openjdk/jdk/pull/15370


More information about the jmh-jdk-microbenchmarks-dev mailing list