I try to benchmark java method calls. The problem with those calls is that they are getting inlined and optimized.
So in the end I try to look for a way to avoid those optimizations. Currently I use:
for(int index = 0; index < 100_000_000; index++)
value = value * 2 % 8;
This calculation is replaced by methods for JNI and Java. The output of the benchmark is:
Druation static jni = 1002ms, instance jni = 1000ms, static java = 136ms, instance java = 140ms, raw = 145ms
Druation static jni = 975ms, instance jni = 974ms, static java = 132ms, instance java = 128ms, raw = 134ms
Druation static jni = 966ms, instance jni = 1084ms, static java = 127ms, instance java = 130ms, raw = 135ms
Druation static jni = 958ms, instance jni = 1083ms, static java = 127ms, instance java = 131ms, raw = 134ms
Druation static jni = 957ms, instance jni = 1085ms, static java = 126ms, instance java = 131ms, raw = 135ms
From the Java vs raw (no methods) one sees the affect of inlining. I would like to know if there is something I can do to prevent inlining?