Significance of JMH annotation parameters
I'm running a benchmarking experiment making HTTP calls using JMH. However, there are couple of things that are not clear to me because the JMH Javadoc are like "here I document the annotation name for you without telling you what it does".
@Fork(value = 2, warmups = 1)
@Warmup(iterations = 1, time = 15)
@Measurement(iterations = 5, time = 15)
@Threads(16)
public class BenchmarkRunner {
@Benchmark
开发者_如何转开发@BenchmarkMode(Mode.Throughput)
public void measureThroughput(Blackhole bh, MyHttpClient client) {
bh.consume(client.exec());
}
}
# Warmup: 1 iterations, 15 s each
# Measurement: 5 iterations, 15 s each
# Timeout: 10 min per iteration
# Threads: 16 threads, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: org.example.BenchmarkRunner.measureThroughput
Questions:
What is the significance of "5 iterations, 15 s each"? Does it mean each iteration will run for 15 seconds within which JMH will make as many calls as possible?
What is the significance of "16 threads, will synchronize iterations"?
I believe these questions to be general in nature. Any more detail would involve analyzing the source code, which is possible here: https://github.com/openjdk/jmh
What is the significance of "5 iterations, 15 s each"? Does it mean each iteration will run for 15 seconds within which JMH will make as many calls as possible?
The Time parameter is used to limit the benchmark operation. The JMH tool will attempt to make as many operations ("calls") in that time as possible.
What is the significance of "16 threads, will synchronize iterations"?
http://hg.openjdk.java.net/code-tools/jmh/file/2be2df7dbaf8/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_17_SyncIterations.java
Per this official sample, "synchronize iterations" means that the threads spun up to operate on the benchmark run are all executing at the same time, thanks to warmup "bogus iterations".
精彩评论