Should I run JMH benchmarks with '-server' option

benchmarking, java, jmh

Solution

Well, it depends on what you are trying to measure. In most cases, the default JVM mode on the machine is what you are after to replicate the same conditions which the ordinary Java application will encounter.

Hence, we usually don't add `-server` to benchmark runs, because on most machines the ergonomics itself implicitly selects it, see Server Class Machine Detection.

Problem

I am using JMH, an OpenJDK microbenchmark tool. The build process creates `microbenchmarks.jar` that I invoke with `java -jar` and passing jar name and JMH arguments. I wonder should we run the benchmarks with `-server` option and why? In other words, should I run my benchmark with: ``` java -server -jar microbenchmarks.jar ...(jmh args) ```

Original source

Related problems