The Computer Language
Benchmarks Game

Java versus C++ g++ fastest programs

Always look at the source code.

These are only the fastest programs. Do some of them use manually vectorized SIMD? 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.93 36,552 764 0.98 2% 3% 1% 99%
C++ g++ 0.60 4,944 986 2.38 100% 100% 98% 100%
fasta
source secs mem gz busy cpu load
Java 1.21 44,620 2543 3.58 89% 75% 65% 68%
C++ g++ 0.78 2,468 2751 1.62 8% 99% 99% 3%
n-body
source secs mem gz busy cpu load
Java 6.74 35,844 1489 6.82 1% 100% 1% 0%
C++ g++ 4.09 1,740 1808 4.26 100% 0% 3% 0%
fannkuch-redux
source secs mem gz busy cpu load
Java 10.64 35,192 1282 41.91 99% 98% 99% 97%
C++ g++ 4.91 1,912 1482 19.45 100% 99% 97% 100%
spectral-norm
source secs mem gz busy cpu load
Java 1.63 39,304 756 6.22 95% 97% 95% 95%
C++ g++ 0.72 1,216 1044 2.86 100% 100% 99% 100%
binary-trees
source secs mem gz busy cpu load
Java 2.48 1,722,848 835 7.88 98% 75% 71% 74%
C++ g++ 1.04 154,824 1122 3.74 88% 100% 88% 86%
reverse-complement
source secs mem gz busy cpu load
Java 1.54 670,924 2183 3.51 46% 56% 48% 79%
C++ g++ 0.63 499,704 2093 0.64 0% 100% 2% 0%
k-nucleotide
source secs mem gz busy cpu load
Java 4.98 356,904 1812 16.25 78% 76% 96% 76%
C++ g++ 1.95 156,372 1631 5.95 73% 70% 92% 70%
mandelbrot
source secs mem gz busy cpu load
Java 4.15 69,136 796 16.29 98% 99% 98% 99%
C++ g++ 0.84 34,604 3542 3.28 98% 99% 98% 95%
regex-redux
source secs mem gz busy cpu load
Java 5.58 985,696 929 18.26 81% 77% 84% 85%
C++ g++ 1.08 203,816 1315 3.38 78% 99% 65% 73%
Java

openjdk 16 2021-03-16
OpenJDK Runtime Environment (build 16+36-2231)
OpenJDK 64-Bit Server VM (build 16+36-2231, mixed mode, sharing)

C++ g++

g++ (Ubuntu 10.2.0-13ubuntu1) 10.2.0