As all of you may know, Java code is compiled and interpreted by JVMs. My questions deal with optimization: Is it optimized at run-time by the JVM only or also at compile-time?
In order to write efficient code, where can I find the list of supported optimizations? Or are JVM optimizations powerful enough so that I just have to write code that is readable and easy to maintain regardless of speed performance?
Most optimisation is done by the JVM. There's generally more scope for optimisation at the JIT level than at compile-time. (The "optimise" flag was actually taken out of javac
, because it turned out that some "optimisations" actually hurt performance in the real world.)
In general (and this applies to many languages/platforms, not just Java):
n
, the "theoretically better" algorithm can easily end up being slower due to constant factors.)