Peer-review JNI Construction tests please

Adam Retter adam.retter at googlemail.com
Sun Dec 22 10:33:10 UTC 2019


Hi there,

I have some benchmarks around timing different mechanisms for
constructing a Java Object which is backed by a C++ Object via JNI -
https://github.com/adamretter/jni-construction-benchmark

I recently modified those benchmarks so that they could also be run
via JMH - https://github.com/adamretter/jni-construction-benchmark/blob/master/src/main/java/com/evolvedbinary/jnibench/jmhbench/ConstructionBenchmark.java

Before JMH, I just ran my benchmark tests in a loop of 1,000,000
iterations, and took readings for 100 JVM iterations. Not very
scientific I know! Previously my tests showed that my FooByCallStatic
test was faster than my FooByCall tests on every instantiation of the
benchmark. The margin between them was small but always present.

With JMH I am finding that sometimes FooByCallStatic is reported as
the best performing, but sometimes FooByCall is reported as the best
performing. I have tried Throughput, AverageTime, and SampleTime for
interpreting the results. I am wondering why sometimes one is reported
faster than the other, when my non-JMH approach shows that
FooByCallStatic is always faster.

Would someone be able to peer-review my 3 simple benchmarks and tell
me if I am taking the correct approach, or if I am doing something
wrong?

Thanks Adam.

-- 
Adam Retter

skype: adam.retter
tweet: adamretter
http://www.adamretter.org.uk


More information about the jmh-dev mailing list