3

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)
assylias
  • 321,522
  • 82
  • 660
  • 783
igr
  • 10,199
  • 13
  • 65
  • 111
  • Please elaborate on the question, it's not clear what you are asking. Should you use `-server` for benchmarking? Should you pass `-server` to JMH launcher? – Aleksey Shipilev Dec 09 '13 at 14:30
  • should I pass '-server' to JVM that runs the microbenchmarks.jar? – igr Dec 09 '13 at 15:08

2 Answers2

9

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.

Aleksey Shipilev
  • 18,599
  • 2
  • 67
  • 86
3

That entirely depends on what you want to benchmark - you should use that option if you want to measure how the system would behave when running server oriented workloads, using server JVM characteristics

see also - What is JVM -server parameter? , indicating that the -server switch also performs better JITting.

Community
  • 1
  • 1
Leeor
  • 19,260
  • 5
  • 56
  • 87
  • I think the same, and all previous microbenchmark tools say something similar; I just couldn't found any such example on JMH site - so I start to think if there is a reason for that ;) Lets see what @Aleksey Shipilev has to say :) – igr Dec 09 '13 at 21:19