callbacks benchmarking

Aleksey Shipilev aleksey.shipilev at oracle.com
Wed Feb 19 12:23:08 PST 2014


On 02/20/2014 12:08 AM, sun gam wrote:
> I have attached some sample use case code, overly simplified ofcourse.

OpenJDK lists strip attachments, so only me got it. Condensing that
example to:

public class Listener {
 private long last;
 void onEvent() {
   long cur = System.nanoTime();
   long interval = cur - last;
   record(interval); // this is what we want to measure
 }
}

I don't understand clearly why would you do this kind of benchmark, but
if you want to count the additional metrics somewhere deep down in your
code, then probably AuxCounters with BenchmarkMode.SampleTime would help?

http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_23_AuxCounters.java

-Aleksey.


More information about the jmh-dev mailing list