JAVA vs C++ Benchmark
Is JAVA fast? Yes, since introduction of SSE and SSE2 streaming commands and other major enhancements, JAVA 1.5 is closing the gap. The best proof is JAKE2 a resource and CPU hungry 3D game engine. Some years ago such an approach would have been laughable.
However the SciMark benchmarks show, that up to 70% of the C++ speed can be reached by JAVA. But there are major differences between operating systems and versions. For the fastest implementation, you should download the free server version of SUNs JAVA engine. This will speed up your code up to 40%. Hence every command must include "java -server" as run command.

Is it a good benchmark? Yes because it contains results from diverse platforms and different CPUs and the code did not change since then. Is it a bad benchmark? Yes, because it only checks for floating point computational speed (good for science, games, applications) and it is only single-threaded (a big NO NO, as it can run only one one CPU core).
Compiler optimization and benchmarks
The free MS Visual C++ Express compiler was compared against the JAVA compiler v1.5 (JAVAC optimization with -O) For comparison a 25% higher clocked Intel CPU result was included, with Intel LINUX C++ compiler.
SCIMARK AMD compiler options
SciMark2 Numeric Benchmark, see http://math.nist.gov/scimark
Opteron 2.8 GHz (single threaded programs) WIN XP2
| WIN XP2 | WIN XP2 | LINUX | ||||||||
| MS Visual C++ | JAVA 1.5 server | Intel C++ | ||||||||
| Opteron 2.8 GHz | Opteron 2.8 GHz | Xeon 3.6 GHz | ||||||||
| fast | precise | SSE fast | SSE precise | SSE2 fast | SSE2 precise | MAX | ||||
| Small Problem | ||||||||||
| Composite Score: | 802.03 | 811.34 | 815.43 | 819.47 | 708.29 | 728.52 | 819.47 | 584 | 943 | |
| FFT Mflops: | 734.42 | 729.5 | 744.13 | 734.42 | 660.7 | 676.32 | 744.13 | 457 | 521 | |
| SOR Mflops: | 868.39 | 927.31 | 868.39 | 920.23 | 822.43 | 893.76 | 927.31 | 906 | 1092 | |
| MonteCarlo Mflops: | 163.63 | 164.38 | 184.75 | 184.75 | 166.78 | 165.96 | 184.75 | 80 | 447 | |
| Sparse matmult Mflops: | 762.49 | 773.29 | 773.29 | 776.72 | 748.98 | 748.98 | 776.72 | 439 | 832 | |
| LU Mflops: | 1481.24 | 1462.2 | 1506.57 | 1481.24 | 1142.54 | 1157.55 | 1506.57 | 1040 | 1827 |
The results together with the JAVA, Assembler and C++ EXE files can be downloaded here. A comprehensive list of different JVM and compiler speeds for several problems can be found at shudo.net. A bunch of other sites comparing JAVA versus C on different platforms and with different JVMs can be found google. The comprehensive JAVAGRANDE benchmarks can be found at EPCC. Another point of interest may be the C# (C-Sharp) version of SciMark, which is slower than JAVA giving a score of 476 on this machine.
The overall speed can be greatly improved by compiling specialized libaries for mathematical functions into the package.
- see JAVA numerics
- see Intel Math Kernel Library
- see AMD Core Math Library (ACML)
Last modified 2008-07-08 10:31 PM