Varying OperationsPerInvocation

Chris Vest mr.chrisvest at gmail.com
Thu Feb 20 01:23:58 PST 2014


Hi,

Say I have a an API that can do operations in batch, and I want to measure how the size of the batches trade off latency and throughput in terms of the individual item in each batch.

Right now, I have to write a @GMB method for each batch size, since the @OperationsPerInvocation value gets inlined into the generated benchmarks, and cannot be adjusted from the command line or through OptionsBuilder.

What I am doing currently, is having a `private static final int` in my benchmark class, that gets initialised from a system property. I then use --jvmArgs to set the system property from the command line for the forked JVMs, and then just live with the fact that the numbers are for multiples of operations.

I was thinking that an approach to do this better, could be that the harness could expose a `public static final long` somewhere, that would be initialised to the value of an --opi (or whatever it would be called) argument, or OptionBuilder equivalent method, or otherwise to the value specified in any @OPI annotation like usual, or 1 by default.
The harness could also choose to complain if one tries to use the --opi on benchmarks that don’t have an @OPI annotation. Or perhaps it should be a new annotation, to signify that the number of operations per invocation is actually adjustable in the benchmark, and not hard-coded.

Cheers,
Chris



More information about the jmh-dev mailing list