I'm trying to log the results from a JMH benchmark. The benchmark is great and works as expected. The problem is in logging the results. Regardless of the ResultFormatType I use, the results output displays NaN for information from the stack profiler.
I understand that this is probably because the stack information is delayed until the summary. How can I add this summary data to the results I am trying to store?
Options opt = new OptionsBuilder().include(".*").warmupIterations(5)
.measurementIterations(5).addProfiler(StackProfiler.class).forks(0).resultFormat(ResultFormatType.CSV)
.result("Benchmark_Results_" + new SimpleDateFormat("dd.MM.yyyy_HH.mm.ss").format(new Date())).build();
Example CSV output.
"Benchmark","Mode","Threads","Samples","Score","Score Error (99.9%)","Unit"
"com.example.com.BenchmarkTest.runBenchmark","avgt",1,5.000000,1.873819,0.132597,"s/op"
"com.example.com.BenchmarkTest.runBenchmark:·stack","avgt",1,1.000000,NaN,NaN,"---"
In JMH, stack profiler produces only a dummy result in the text report table, as a result of deficiency in reporting code that needs a scalar result from benchmark and profilers. You may ignore it completely. Look at the benchmark output for profiling results.
There is no clear way to store the stack profiling results as the bunch of scalars.