Java – why does jmh run different forks?
I use the jmh benchmark framework( http://openjdk.java.net/projects/code-tools/jmh/ )Run the benchmark on my code My understanding is that jmh allocates the JVM multiple times during the analysis process in order to discard any configuration files built by the just in time (JIT) analysis performed by the JVM during execution
I understand why this is useful in some cases, such as the following (from http://java-performance.info/jmh/ Verbatim copy):
However, if you benchmark the same code repeatedly, is there any advantage in running 10 forks of 20 iterations instead of 1 and 200 iterations?
Thank you.
Danny
Solution
Another problem that some people insist on using forks to solve is the operating variance: http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_13_RunToRun.java
However, any serious engineer must have sufficient control over the baseline environment to eliminate any differences between operations It is frustrating to see people using forks to overcome laziness or lack of understanding of the actual implementation of benchmarks