The Computer Language
Benchmarks Game

Java programs versus C++ g++

by benchmark task performance

regex-redux
source secs mem gz cpu cpu load
Java 12.31 902,528 929 38.75 73% 76% 86% 81%
C++ g++ 17.14 220,088 853 25.22 95% 3% 51% 1%
k-nucleotide
source secs mem gz cpu cpu load
Java 7.93 465,372 1802 25.11 75% 75% 75% 93%
C++ g++ 7.18 164,052 1252 24.28 83% 83% 93% 83%
fannkuch-redux
source secs mem gz cpu cpu load
Java 13.74 30,368 1282 54.12 100% 98% 98% 99%
C++ g++ 10.35 2,624 980 40.60 99% 99% 100% 95%
fasta
source secs mem gz cpu cpu load
Java 2.13 36,036 2457 5.66 94% 58% 59% 60%
C++ g++ 1.48 4,176 2313 5.25 89% 90% 88% 89%
pidigits
source secs mem gz cpu cpu load
Java 3.06 31,760 938 3.16 6% 3% 97% 1%
C++ g++ 1.89 3,868 508 1.89 100% 1% 2% 1%
reverse-complement
source secs mem gz cpu cpu load
Java 1.10 345,352 1661 2.40 33% 82% 53% 54%
C++ g++ 0.60 211,852 2275 0.98 38% 25% 82% 27%
spectral-norm
source secs mem gz cpu cpu load
Java 4.29 29,884 950 16.56 96% 97% 99% 95%
C++ g++ 1.99 1,880 1044 7.89 100% 99% 99% 99%
n-body
source secs mem gz cpu cpu load
Java 21.54 27,092 1489 21.56 1% 1% 100% 1%
C++ g++ 9.31 1,052 1544 9.30 1% 1% 1% 100%
mandelbrot
source secs mem gz cpu cpu load
Java 7.10 90,588 796 27.92 99% 99% 98% 98%
C++ g++ 1.73 34,064 1002 6.80 98% 98% 98% 99%
binary-trees
source secs mem gz cpu cpu load
Java 11.26 593,156 835 39.02 85% 88% 90% 88%
C++ g++ 2.36 114,404 809 7.69 86% 71% 87% 85%
Java

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

C++ g++

g++ (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406