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 1.83 34,848 764 1.95 99% 1% 4% 2%
C++ g++ 1.82 4,312 513 1.87 1% 1% 2% 100%
fannkuch-redux
source secs mem gz busy cpu load
Java 16.12 33,168 1282 63.71 100% 98% 99% 98%
C++ g++ 10.71 1,708 980 42.33 100% 96% 100% 100%
fasta
source secs mem gz busy cpu load
Java 2.22 43,096 2473 6.10 67% 83% 45% 80%
C++ g++ 1.46 2,024 2711 4.40 75% 76% 75% 76%
reverse-complement
source secs mem gz busy cpu load
Java 3.27 714,144 2183 7.54 47% 60% 66% 58%
C++ g++ 1.89 499,672 2093 1.94 100% 2% 1% 1%
spectral-norm
source secs mem gz busy cpu load
Java 4.15 36,428 950 16.26 98% 100% 98% 97%
C++ g++ 1.99 2,408 1044 7.89 99% 99% 99% 99%
binary-trees
source secs mem gz busy cpu load
Java 8.28 948,040 835 28.20 80% 84% 87% 90%
C++ g++ 3.96 113,236 809 12.86 74% 84% 98% 69%
k-nucleotide
source secs mem gz busy cpu load
Java 9.14 403,576 1812 29.10 87% 72% 74% 86%
C++ g++ 3.88 156,164 1631 12.09 72% 92% 71% 77%
n-body
source secs mem gz busy cpu load
Java 21.85 34,112 1489 22.16 1% 0% 0% 100%
C++ g++ 7.70 1,612 1879 7.81 100% 0% 1% 1%
mandelbrot
source secs mem gz busy cpu load
Java 6.84 76,008 796 26.90 99% 98% 98% 98%
C++ g++ 1.51 26,256 1791 6.01 100% 99% 99% 99%
regex-redux
source secs mem gz busy cpu load
Java 10.27 635,500 740 29.42 74% 81% 55% 76%
C++ g++ 1.86 203,856 1315 4.49 99% 50% 48% 44%
Java

openjdk 14 2020-03-17
OpenJDK Runtime Environment (build 14+36-1461)
OpenJDK 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)

C++ g++

g++ (Ubuntu 9.3.0-10ubuntu2) 9.3.0