The Computer Language
Benchmarks Game

C++ g++ versus Java 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.

regex-redux
source secs mem gz busy cpu load
C++ g++ 1.85 203,748 1315 4.44 48% 100% 43% 48%
Java 10.31 644,560 740 31.47 72% 72% 92% 70%
mandelbrot
source secs mem gz busy cpu load
C++ g++ 1.51 25,708 1791 6.01 99% 99% 99% 100%
Java 6.83 79,108 796 26.86 97% 99% 99% 99%
n-body
source secs mem gz busy cpu load
C++ g++ 7.70 1,772 1879 8.02 4% 0% 0% 100%
Java 21.93 35,408 1429 22.44 1% 0% 100% 1%
k-nucleotide
source secs mem gz busy cpu load
C++ g++ 3.89 156,148 1631 11.99 94% 74% 70% 71%
Java 9.33 447,976 1812 29.36 73% 83% 82% 77%
spectral-norm
source secs mem gz busy cpu load
C++ g++ 1.98 2,320 1044 7.90 99% 100% 99% 100%
Java 4.22 36,948 950 16.43 98% 97% 98% 96%
binary-trees
source secs mem gz busy cpu load
C++ g++ 3.93 113,768 809 12.78 70% 81% 75% 98%
Java 8.32 953,620 835 28.37 95% 87% 81% 77%
pidigits
source secs mem gz busy cpu load
C++ g++ 1.89 4,460 513 1.95 2% 0% 100% 1%
Java 3.07 39,320 938 3.31 2% 5% 3% 98%
fasta
source secs mem gz busy cpu load
C++ g++ 1.46 2,180 2711 4.39 75% 75% 75% 75%
Java 2.22 45,172 2473 5.99 61% 50% 98% 60%
fannkuch-redux
source secs mem gz busy cpu load
C++ g++ 10.70 1,864 980 42.31 96% 100% 100% 100%
Java 14.33 34,888 1282 56.56 99% 98% 99% 98%
reverse-complement
source secs mem gz busy cpu load
C++ g++ 4.72 500,116 840 4.76 100% 0% 0% 0%
Java 3.16 712,368 2183 7.08 65% 47% 42% 70%
C++ g++

g++ (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008

Java

openjdk 13 2019-09-17
OpenJDK Runtime Environment (build 13+33)
OpenJDK 64-Bit Server VM (build 13+33, mixed mode, sharing)