AuxCounters

Aleksey Shipilev shade at redhat.com
Mon Mar 6 18:27:16 UTC 2017


Hi Henry,

On 03/06/2017 05:17 PM, Henri Tremblay wrote:
> I want to do something basic but haven't found a way.

This is not as basic as you'd think.

> I played with auxiliary counters but after reading the doc, I've definitely
> failed to understand it it seems.
> 
> I want to do this:
> 
> @Benchmark
> @Threads(Threads.MAX)
> public String cacheAccess() {
> 
>    return cache.get(key);
> 
> }
> 
> And have the time when the method returns null and when if returns
> something else.
> 
> Is there a way?

No, there is no way. @AuxCounters work for Throughput/AverageTime because they
can record "counters" that you can increment. If you want conditional per-sample
timing measurement, that is not enough.

-Aleksey



More information about the jmh-dev mailing list