How annoying
incorrect comparisons of platforms are . Leaving aside the differences between .NET and Java, which were not taken into account in the test, I will show the optimization of execution time in steps.
1. Just start up. The number of iterations is reduced from 30 million to 5 million, but this is repeated (for JIT) 10 times
6663
6199
6322
6540
5095
6033
6741
5045
6253
5142
average = 6003, div = 663
Is it possible to compare something with this variation? Well, if you really want to ... but go on.
')
2. Application launch parameters are set to "-server -Xmx1024M -XX: -UseParallelGC -XX: -UseParallelOldGC -XX: + AggressiveOpts -XX: + UseBiasedLocking".
5681
4990
5202
4950
5892
5415
5270
5739
5200
5130
average = 5346, div = 324
3. As a JVM, 1.7.0 beta x64 is used (x86 is swinging)
4146
3099
3542
3542
3125
3199
3545
3104
3653
3149
average = 3410, div = 340
4. If we are testing a tree, but on random, then it is not clear why we need a new object every time. We will use a constant Object, at the same time it will save us from boxing / unboxing
private final static Object OBJECT = new Object ();
Tree tree = new Tree (r.nextInt (), OBJECT); // first element
tree.add (r.nextInt (), OBJECT);
3310
2960
2795
2980
3293
3002
2803
2785
3047
2798
average = 2977, div = 197
5. Last JVM beta x86 downloaded ...
2932
2724
3198
2647
2597
2954
2896
2648
2572
2844
average = 2801, div = 199
6. And for comparison, we'll completely remove OBJECT from the code, as the author of the original topic did
2855
2679
3083
2566
2517
2953
2634
2640
3108
2681
average = 2772, div = 213
Conclusion
I am sure that such minor improvements are available in both Java and .NET. The use of “microtests” for comparing the performance of platforms is inefficient, it creates only “topics of evil” and is useful only for the overall development of the programmer.