If I want to compare the speed of 2 implementations of an algorithm, is there any gotcha about the JIT I should be aware of? For example, how many iterations does it take the JIT to “warm-up” (if it does – I am not very familiar with the JIT)? I have a merge-like algorithm in mind, where I want to compare using an iterator and using raw primitive arrays directly. I want to understand how well the JIT can handle the iterator-based algorithm.
My fear is that my comparison wouldn’t be relevant because I didn’t let the benchmark run long enough, and the JIT didn’t really have a chance to do its job.
Also, what would be the best reference to understand the JIT in depth (besides reading source code).
- One more question: is -server the best option to use to tell the JIT to work hard?
too many to mention. 😉
Don’t forget the CPU and cache does its own optimisation and performance improvements.
At least 10,000. I would perform the test for 2-10 seconds, a number of times.
I don’t think there is one “best” reference. Its a very complex subject.