I've heard a lot about how JIT compilation makes code run faster than precompiled one when talking about "long-running" applications. But how long does it take to completely optimise your application?
Just for interest's sake, I'll show you example. I have some method, let's call it mySlowMethod()
. It performs some matrix calculations such as rotation, multiplication and so on a few hundred times per second. I've measured a time of each call and got these results:
long time = System.nanoTime();
mySlowMethod();
System.out.println(System.nanoTime()-time);
//first call
1577187 (1.6 ms)
//next 2 seconds
~60000 (0.06 ms)
//later
less than 10000 (0.01 ms)
The JIT actually operates in multiple smaller steps to minimize the performance impact on application start-up. These steps include:
Multiple modes.
Incremental compilation.
Overall, the application is probably never "fully optimized", but you'd never know this because the parts you actually cared about were optimized early.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.