Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding JMH Output

Tags:

java

jmh

So I ran a JMH Benchmark over a few methods and got response like this:

enter image description here

I am not able to understand what exactly the Score and Error values signify.

Is there some reference documentation available for the same?

like image 917
AgentX Avatar asked Nov 09 '15 07:11

AgentX


People also ask

What is JMH benchmark?

JMH (Java Microbenchmark Harness) is a library for writing benchmarks on the JVM, and it was developed as part of the OpenJDK project. It is a Java harness for building, running, and analyzing benchmarks of performance and throughput in many units, written in Java and other languages targeting the JVM.

What is JMH operation?

In JMH, "operation" is an abstract unit of work. See e.g. the sample result: Benchmark Mode Cnt Score Error Units MyBenchmark.testMethod avgt 5 5.068 ± 0.586 ns/op. Here, the performance is 5.068 nanoseconds per operation. Nominally, one operation is one @Benchmark invocation.

How do you run JMH?

There are two ways to run the JMH benchmark, uses Maven or run it via a JMH Runner class directly. 3.1 Maven, package it as a JAR and run it via org. openjdk. jmh.

What is JMH fork?

@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.


1 Answers

As an example, ss_stream with parameters n=100000 took ca. 1,363 microseconds to run on average over 30 iterations (and was run a number of times in each of these iterations, depending on the length of each iteration).

Assuming that the results are normally distributed, for that sample size, one would expect that the "true" execution time for that method has a 99.9% probability to be somewhere between 1,362.752 - 126.340 microseconds and 1,362.752 + 126.340 microseconds, i.e. between ca. 1,236 and 1,489.

As far as I know, the main documentation is in the samples. The second one gives information about the various benchmark modes.

like image 83
assylias Avatar answered Sep 28 '22 08:09

assylias