microbenchmarking a component that encapsulates a threading service

Aleksey Shipilev aleksey.shipilev at oracle.com
Wed May 18 22:33:27 UTC 2016


On 05/18/2016 11:19 PM, Thondepu, Raj wrote:
> Friends:
> 
> I have a case where I am trying to benchmark a tightly encapsulated
> producer-consumer component where I have handle only to publish to it
> and receive a call back on the listener. Needless to say, the thread
> calling the listener is a component thread.  Is there a way to
> benchmark the listener throughput?
> 
> To my understanding @Benchmark uses jmh's own threads to call and
> benchmark declared methods.  I was wondering if there is any way to
> let jmh override my listener call and time it.

No.

At this point, JMH expects the payload code to be in the synchronous
@Benchmark method, called by the JMH itself. It does not time any
external methods. I would think that's a job for a profiler attached to
a workload running under a load generator.

You can put listener code into @Benchmark method and run it with data
that is usually fed into it, turning this into a usual targeted benchmark.

Or you can put the producer code into @Benchmark method and measure the
injection rate, assuming that in stable conditions the producer
throughput is equal to consumer throughput. (Basically producer is both
load gen and a payload here).

Thanks,
-Aleksey



More information about the jmh-dev mailing list