I'm learning JMH benchmarking using this tutorial.
I noticed that there are 2 warmup related stuff for function benchMurmur3_128 in here.
so, I have question regarding the difference between warmup attribute in Fork annotation and Warmup annotation with iterations attribute?
Warmup annotation allows to set the default warmup parameters for the benchmark. This annotation may be put at Benchmark method to have effect on that method only, or at the enclosing class instance to have the effect over all Benchmark methods in the class. This annotation may be overridden with the runtime options.
@Fork annotation, instructs how benchmark execution will happen the value parameter controls how many times the benchmark will be executed, and the warmup parameter controls how many times a benchmark will dry run before results are collected.
With a JMH benchmark you run one or more forks sequentially, and one or more iterations of your benchmark code within each fork. There are two forms of warmup associated with this:
For example:
So the overall impact of the warmup settings shown above is that:
That is why the JMH output below (which was run using those annotations against the benchmarked method) shows Cnt 12 at the end of the run: 3 forks x 4 iterations = 12.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With