Code in the question is a bad test example. As the answer shows, different compilers can optimize the code in different ways to make the outer loop almost meaningless. A better test would have 100000 different arrays to test.
Did you enable optimizations in C++ and disable adaptive optimization in java?
5 comments
[ 3.2 ms ] story [ 19.4 ms ] threadhttps://www.hnsearch.com/search#request/submissions&q=Why+is...
Discussion: https://news.ycombinator.com/item?id=4637196
Sort before adding tiny values.
Did you enable optimizations in C++ and disable adaptive optimization in java?