The Computer Language
Benchmarks Game

C++ g++ programs versus Java

by benchmark task performance

regex-redux
source secs mem gz cpu cpu load
C++ g++ 1.61 203,572 1315 4.18 100% 52% 57% 54%
Java 10.34 627,224 929 29.88 74% 72% 65% 79%
mandelbrot
source secs mem gz cpu cpu load
C++ g++ 1.64 27,636 1002 6.51 100% 99% 100% 99%
Java 6.04 76,528 796 23.34 98% 97% 97% 97%
binary-trees
source secs mem gz cpu cpu load
C++ g++ 2.55 135,568 809 7.99 85% 96% 69% 66%
Java 8.34 893,008 835 28.20 87% 79% 96% 81%
n-body
source secs mem gz cpu cpu load
C++ g++ 8.23 1,856 1763 8.23 100% 1% 1% 0%
Java 22.10 33,136 1429 22.20 31% 1% 1% 70%
spectral-norm
source secs mem gz cpu cpu load
C++ g++ 2.02 1,332 1044 7.91 99% 99% 99% 99%
Java 4.23 34,472 950 16.27 96% 97% 97% 96%
pidigits
source secs mem gz cpu cpu load
C++ g++ 1.88 4,276 513 1.88 0% 100% 1% 0%
Java 3.12 36,788 938 3.31 6% 3% 4% 96%
fannkuch-redux
source secs mem gz cpu cpu load
C++ g++ 10.61 2,044 980 41.90 100% 96% 100% 100%
Java 17.26 32,116 1282 67.75 98% 99% 97% 99%
reverse-complement
source secs mem gz cpu cpu load
C++ g++ 0.64 247,800 2280 1.03 89% 22% 31% 30%
Java 1.03 191,064 2183 2.31 52% 57% 43% 74%
fasta
source secs mem gz cpu cpu load
C++ g++ 1.49 4,372 2324 5.28 89% 88% 90% 90%
Java 2.33 43,924 2473 6.07 53% 71% 63% 74%
k-nucleotide
source secs mem gz cpu cpu load
C++ g++ 7.75 165,180 1276 26.02 80% 96% 82% 79%
Java 8.70 375,568 1812 27.17 80% 72% 74% 88%
C++ g++

g++ (Ubuntu 7.2.0-8ubuntu3) 7.2.0

Java

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