Why I am getting weird benchmark results between 0.99 and 100 percentile

Sarath Babu sarath.chalasani46 at gmail.com
Thu May 6 05:18:09 UTC 2021


Hi Team,

When I run the JMH benchmark results using simpletime mode getting weird
benchmark results between 0.99 and 100 percentile, could you please provide
me a reasons behind.

*Results* :
Benchmark                                                            Mode
     Cnt     Score   Error  Units
CacheTest.measureCacheGet                                          sample
 152939771     0.050 ± 0.001  ms/op
CacheTest.measureCacheGet:measureCacheGet·p0.00                    sample
             0.001          ms/op
CacheTest.measureCacheGet:measureCacheGet·p0.50                    sample
             0.001          ms/op
CacheTest.measureCacheGet:measureCacheGet·p0.90                    sample
             0.002          ms/op
CacheTest.measureCacheGet:measureCacheGet·p0.95                    sample
             0.003          ms/op
CacheTest.measureCacheGet:measureCacheGet·p0.99                    sample
             0.003          ms/op
CacheTest.measureCacheGet:measureCacheGet·p0.999                   sample
             0.006          ms/op
CacheTest.measureCacheGet:measureCacheGet·p0.9999                  sample
           136.839          ms/op
CacheTest.measureCacheGet:measureCacheGet·p1.00                    sample
          4487.905          ms/op

*Code snippet:*

@Benchmark

@BenchmarkMode({ Mode.*SampleTime* })

@OutputTimeUnit(TimeUnit.*MILLISECONDS*)

@Warmup(iterations = 3)

@Measurement(iterations = 10)

*public* *void* measureCacheGet(CachePut cPut, RandomNumberBelowLakh rNum)
*throws* InterruptedException {

cPut.cache.get(rNum.key);

}


        @State(Scope.*Thread*)

*public* *static* *class* RandomNumberBelowLakh {


*public* *long* key;


@Setup(Level.*Invocation*)

*public* *void* doSetup() {

key = getRandomNumber();

}


@TearDown(Level.*Invocation*)

*public* *void* doTearDown() {

key=0;

}

*public* *long* getRandomNumber() {

*return* (*long*) ((Math.*random*() * (100000 - 1)) + 1);

}

}


@State(Scope.*Benchmark*)

*public* *static* *class* CachePut {


*public* CacheManagerImpl impl;

*public* Cache cache;


@Setup

*public* *void* setup() {

impl = *new* CacheManagerImpl();

cache = impl.getCache("account");

cachePutAccountObjects();

}


*public* *void* cachePutAccountObjects() {

*for* (*long* i = 1; i <= 100000; i++) {

cache.put(i, AccountUtil.*getAccount*(i));

}

}


@TearDown

*public* *void* doTearDown() {

impl = *null*;

cache = *null*;

}

}




Thanks and Regards
C.Sarathbabu
Cont No: 9652511597


More information about the jmh-dev mailing list