Custom and not-constant "Operations per invocation" (Re: JMH 1.15)

Lev Serebryakov lev at serebryakov.spb.ru
Tue Oct 4 11:57:57 UTC 2016


On 04.10.2016 13:48, Aleksey Shipilev wrote:

> You have to use Java API for this, and override
> .operationsPerInvocation(...) to match your .params(...) if you want to
> normalize the operations like that.
 Override on what class? I've read JHM sources, and looks like runner
calls getOperationsPerInvocation() from options builder only once per
benchmark (but I may be wrong, of course). And in my case, it is
different on EACH call of @Bencmark'ed method. And only this method
itself know how much work was done at this invocation. I don't see how
building options by hands helps in such situation.

 And my situation is more complicated than that: it is non-symmetrical
two-thread (consumer/producer) benchmark, where consumer and producer
could use very different (random) values of OPI (and spent time, too!),
and this difference could be 2 orders of magnutude. As result, "primary
metrics" is completely meaningless now :(

 But, I should say, that @AuxCounters gives very stable "good-looking"
results with very low stddev between runs. Maybe, they are not
ns-precise (co, not suitable to estimating low-level characteristics
like CPI and such), but looks suitable for comparing different
implementations of same API.

-- 
// Black Lion AKA Lev Serebryakov



More information about the jmh-dev mailing list