When writing microbenchmarks, one can observe a large difference in runtime depending on whether a method has been compiled or not. Is there a way to tell from within a program whether a particular method has been compiled? Alternatively, is there a way to request it, or to know how to warm it up adequately without any extra information about e.g. flags passed to the JVM? Obviously this will not necessarily be perfect (e.g. there may be some condition present that causes the JVM to fall back to interpreted code), but it would certainly be an improvement.
When writing microbenchmarks, one can observe a large difference in runtime depending on whether
Share
For Sun/Oracle JVM you can use the
-XX:CompileThreshold=1000setting.This – as the official documentation states – defines:
Then, just use the number to “warm up” the JVM.
You can also use the
-XX:-PrintCompilationtogether with-XX:CompileThresholdin order to be notified (in the console) when a method is compiled.