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.79 35,568 764 0.84 99% 3% 3% 1%
C++ g++ 0.60 4,944 986 2.38 100% 100% 98% 100%
fannkuch-redux
source secs mem gz busy cpu load
Java 11.00 34,104 1282 43.42 99% 98% 98% 99%
C++ g++ 8.08 1,900 980 31.45 98% 100% 98% 93%
fasta
source secs mem gz busy cpu load
Java 1.20 44,124 2543 3.61 79% 86% 69% 65%
C++ g++ 0.78 2,468 2751 1.62 8% 99% 99% 3%
n-body
source secs mem gz busy cpu load
Java 6.75 35,200 1489 6.83 0% 0% 100% 1%
C++ g++ 4.09 1,800 1808 4.13 100% 0% 0% 0%
spectral-norm
source secs mem gz busy cpu load
Java 1.68 38,348 950 6.43 96% 96% 96% 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.50 2,487,096 835 7.90 88% 75% 75% 79%
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 702,332 2183 3.55 78% 46% 49% 57%
C++ g++ 0.63 499,704 2093 0.64 0% 100% 2% 0%
k-nucleotide
source secs mem gz busy cpu load
Java 5.00 408,040 1812 16.36 74% 81% 86% 86%
C++ g++ 1.95 156,372 1631 5.95 73% 70% 92% 70%
mandelbrot
source secs mem gz busy cpu load
Java 4.11 68,204 796 16.20 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.70 656,328 929 18.25 89% 76% 79% 75%
C++ g++ 1.08 203,816 1315 3.38 78% 99% 65% 73%
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 10.2.0-13ubuntu1) 10.2.0