The Computer Language
Benchmarks Game

Java programs versus C++ g++

by benchmark task performance

regex-redux
source secs mem gz cpu cpu load
Java 10.38 634,548 929 29.48 70% 64% 69% 82%
C++ g++ 17.14 220,088 853 25.22 95% 3% 51% 1%
k-nucleotide
source secs mem gz cpu cpu load
Java 8.38 375,988 1802 26.25 73% 97% 70% 74%
C++ g++ 7.18 164,052 1252 24.28 83% 83% 93% 83%
fannkuch-redux
source secs mem gz cpu cpu load
Java 15.09 34,764 1282 59.26 99% 98% 98% 100%
C++ g++ 10.35 2,624 980 40.60 99% 99% 100% 95%
fasta
source secs mem gz cpu cpu load
Java 2.32 46,816 2457 6.37 61% 60% 96% 60%
C++ g++ 1.48 4,176 2313 5.25 89% 90% 88% 89%
pidigits
source secs mem gz cpu cpu load
Java 3.12 37,444 938 3.30 2% 5% 98% 4%
C++ g++ 1.89 3,868 508 1.89 100% 1% 2% 1%
reverse-complement
source secs mem gz cpu cpu load
Java 1.13 199,672 2124 2.76 48% 74% 70% 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.25 36,364 950 16.30 97% 96% 95% 97%
C++ g++ 1.99 1,880 1044 7.89 100% 99% 99% 99%
n-body
source secs mem gz cpu cpu load
Java 22.56 35,208 1424 22.65 99% 1% 1% 1%
C++ g++ 9.31 1,052 1544 9.30 1% 1% 1% 100%
mandelbrot
source secs mem gz cpu cpu load
Java 6.08 77,056 796 23.61 97% 97% 99% 97%
C++ g++ 1.73 34,064 1002 6.80 98% 98% 98% 99%
binary-trees
source secs mem gz cpu cpu load
Java 8.58 966,808 835 28.98 86% 84% 90% 81%
C++ g++ 2.36 114,404 809 7.69 86% 71% 87% 85%
Java

java 9
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

C++ g++

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