You have a loop which doesn't do anything useful. As such the JIT can take some time to detect this and eliminate the loop. In the first four examples, the code is taking an average of a fraction of a clock cycle. This is a strong hint that the loop has been optimised away and you are actually measuring how long it takes to detect and replace the loop with nothing,
In the later examples, the loop is not optimised away because there is something about the loop which the JIT doesn't eliminate. I suspected it was the object allocation for the Integer
but -verbosegc
showed that no objects were being created.
On my machine the loop take about 1.9 ns or about 6 clock cycles which is pretty quick so I am not sure what is left which takes that much time..