Java benchmarking – why is the second loop faster?

This is a classic java benchmarking issue. Hotspot/JIT/etc will compile your code as you use it, so it gets faster during the run.

Run around the loop at least 3000 times (10000 on a server or on 64 bit) first – then do your measurements.

Leave a Comment