sometime output twice, sometime output once
Aleksey Shipilev
shade at redhat.com
Thu Mar 9 17:07:30 UTC 2017
Hi,
On 03/05/2017 05:54 PM, t_liang wrote:
> # Run progress: 0.00% complete, ETA 00:03:02
> # Fork: 1 of 1
> Iteration 1: why1 0.999 ops/s
>
> # Run progress: 0.55% complete, ETA 00:04:20
> # Fork: 1 of 1
> Iteration 1: why2 why2 0.989 ops/s
>
There are no guarantees that @Benchmark method would get executed exactly once,
unless you are running in SingleShot mode.
In other modes, harness may elect to run the method several times, for several
reasons:
a) Intrinsic race between the thread that announces the iteration finish, and
the measurement threads. This is especially possible if you sleep for *just* the
iteration time;
b) In multi-threaded scenarios, "synchronize iterations" would run pre- and
post- loops that are not measured towards performance metrics, but provide
proper warmup/warmdown.
Thanks,
-Aleksey
P.S. It would be good if you can pose the question in message body, not in
subject alone.
More information about the jmh-dev
mailing list