JMH difference between Sample and SingleShot
Asked Answered
B

1

6

What's the difference between setting Mode.Sample and Mode.SingleShot together with measurementIterations set to large number? Is it effectively the same or is there some quantitive difference between the two modes?

Bilious answered 27/1, 2016 at 16:40 Comment(0)
O
16

But... Javadoc states the difference quite specifically?

Sample time: samples the time for each operation.

Runs by continuously calling {@link Benchmark} methods, and randomly samples the time needed for the call. This mode automatically adjusts the sampling frequency, but may omit some pauses which missed the sampling measurement. This mode is time-based, and it will run until the iteration time expires.

And:

Single shot time: measures the time for a single operation.

Runs by calling {@link Benchmark} once and measuring its time. This mode is useful to estimate the "cold" performance when you don't want to hide the warmup invocations, or if you want to see the progress from call to call, or you want to record every single sample. This mode is work-based, and will run only for a single invocation of {@link Benchmark} method.

Caveats for this mode include:

  • More warmup/measurement iterations are generally required.
  • Timers overhead might be significant if benchmarks are small; switch to {@link #SampleTime} mode if that is a problem.
Overstay answered 28/1, 2016 at 8:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.