<< Back to the The Java is Faster than C++ and C++ Sucks Unbiased Benchmark November 14, 2003

UPDATE July 2010:
Despite its obvious flaws, this benchmark continues drawn a lot of attention and e-mail. The reason I posted it nearly seven years ago was not to prove anything, but rather to spark conversation. Prior to my results being published on Slashdot and the like, there was little discussion in the public sphere about whether JIT runtimes could even compare to native compiled languages' performance. To that end, I think this project succeeded in bringing such a dialogue into the developer world, and while this benchmark may not be perfect, this was a starting point for more thorough treatments and analyses of the subject.

Performance Graph
Times (smaller is better)

(The "winner" of each benchmark is highlighted in green;
the loser is highlighted in red.)

G++ 3.3.1 Java 1.4.2
Intel 386 Intel 686 Server JVM Client JVM
Ackermann 60.95 39.03 34.53 N/A*
Fibonacci 49.41 43.13 33.12 49.78
Hash2 21.11 21.62 9.96 14.56
Hash 16.43 16.51 7.93 86.76
Heapsort 20.04 19.63 21.59 20.47
Matrix 10.58 10.76 14.95 30.55
Method call 24 20.49 2.47 39.18
Nested loop 12.63 15.08 23.42 32.57
Object creation 24.88 23.47 6.4 7.17
Random no. gen. 21.29 15.12 29.99 57.08
Sieve 16.54 16.53 15.08 16.66
String concatenation 2.49 1.79 2.6 2.99
Sumcol 9.11 8.51 6.69 12.75
Word count 4.37 4.27 3.02 3.89
Performance rating (bigger is better)
(see graph)
G++ 3.3.1 Java 1.4.2
Intel 386 Intel 686 Server JVM Client JVM
Ackermann 73% 114% 129% N/A*
Fibonacci 88% 101% 132% 88%
Hash2 79% 77% 168% 115%
Hash 194% 193% 402% 36%
Heapsort 101% 104% 94% 99%
Matrix 157% 155% 111% 54%
Method call 89% 105% 871% 54%
Nested loop 165% 138% 89% 64%
Object creation 62% 65% 241% 215%
Random no. gen. 145% 204% 102% 54%
Sieve 97% 98% 107% 97%
String concatenation 99% 137% 94% 82%
Sumcol 101% 108% 138% 72%
Word count 88% 91% 128% 99%

*The Client JVM could not run the Ackermann test without producing a StackOverflowError.