The Computer Language
Benchmarks Game

Java versus C++ g++ fastest programs

Always look at the source code.

These are only the fastest programs. Look at the other programs. They may seem more-like a fair comparison to you.

pidigits
source secs mem gz busy cpu load
Java 0.94 35,604 764 0.99 1% 4% 3% 97%
C++ g++ 0.89 4,236 513 0.89 0% 0% 100% 0%
fannkuch-redux
source secs mem gz busy cpu load
Java 9.94 34,188 1282 39.21 99% 98% 99% 97%
C++ g++ 7.92 1,700 980 30.88 100% 99% 98% 93%
fasta
source secs mem gz busy cpu load
Java 1.28 44,172 2473 4.17 83% 78% 88% 76%
C++ g++ 0.85 2,020 2711 3.13 92% 92% 92% 93%
n-body
source secs mem gz busy cpu load
Java 6.76 35,156 1489 6.83 1% 0% 100% 1%
C++ g++ 3.94 1,604 1808 4.02 0% 1% 100% 1%
binary-trees
source secs mem gz busy cpu load
Java 2.49 2,490,296 835 7.88 92% 75% 78% 72%
C++ g++ 1.16 200,288 890 4.19 89% 88% 87% 98%
spectral-norm
source secs mem gz busy cpu load
Java 1.66 38,280 950 6.36 97% 95% 96% 96%
C++ g++ 0.72 2,348 1044 2.84 100% 99% 99% 99%
reverse-complement
source secs mem gz busy cpu load
Java 1.53 720,672 2183 3.57 52% 63% 59% 59%
C++ g++ 0.63 499,668 2093 0.64 2% 0% 0% 100%
k-nucleotide
source secs mem gz busy cpu load
Java 4.88 409,508 1812 15.86 75% 88% 86% 77%
C++ g++ 1.98 156,108 1631 5.92 96% 67% 68% 68%
mandelbrot
source secs mem gz busy cpu load
Java 4.15 70,040 796 16.34 98% 98% 99% 98%
C++ g++ 0.89 34,540 3542 3.47 98% 98% 97% 99%
regex-redux
source secs mem gz busy cpu load
Java 5.58 656,192 929 17.84 83% 83% 80% 74%
C++ g++ 1.03 275,752 2850 2.19 36% 37% 100% 40%
Java

openjdk 15 2020-09-15
OpenJDK Runtime Environment (build 15+36-1562)
OpenJDK 64-Bit Server VM (build 15+36-1562, mixed mode, sharing)

C++ g++

g++ (Ubuntu 9.3.0-10ubuntu2) 9.3.0