The Computer Language
Benchmarks Game

C++ g++ programs versus Java

by benchmark task performance

binary-trees
source secs mem gz cpu cpu load
C++ g++ 3.36 158,320 846 10.59 81% 82% 78% 75%
Java 11.52 643,924 889 40.54 89% 92% 85% 89%
n-body
source secs mem gz cpu cpu load
C++ g++ 9.30 1,712 1763 9.29 100% 1% 1% 0%
Java 21.50 27,240 1489 21.52 1% 1% 100% 0%
spectral-norm
source secs mem gz cpu cpu load
C++ g++ 2.01 1,792 1044 8.00 100% 100% 100% 100%
Java 4.29 31,428 950 16.56 97% 96% 98% 97%
reverse-complement
source secs mem gz cpu cpu load
C++ g++ 0.59 217,564 2275 0.84 26% 78% 12% 34%
Java 1.11 345,308 1661 2.44 33% 58% 54% 80%
regex-redux
source secs mem gz cpu cpu load
C++ g++ 6.75 183,256 700 9.80 100% 39% 8% 0%
Java 12.16 927,212 929 37.28 73% 81% 75% 78%
fannkuch-redux
source secs mem gz cpu cpu load
C++ g++ 10.58 2,520 950 41.88 100% 100% 99% 98%
Java 17.74 30,048 1282 69.90 98% 98% 100% 99%
pidigits
source secs mem gz cpu cpu load
C++ g++ 1.89 3,740 508 1.89 2% 99% 0% 2%
Java 3.06 31,088 938 3.16 0% 3% 9% 92%
fasta
source secs mem gz cpu cpu load
C++ g++ 1.47 9,484 2291 5.13 88% 88% 87% 88%
Java 2.14 36,192 2457 5.68 71% 58% 62% 77%
k-nucleotide
source secs mem gz cpu cpu load
C++ g++ 7.15 164,080 1252 24.21 82% 83% 80% 96%
Java 8.02 467,004 1802 25.57 76% 98% 73% 74%
mandelbrot
source secs mem gz cpu cpu load
C++ g++ 5.82 33,952 726 22.40 96% 95% 95% 100%
Java 5.89 89,504 796 23.08 98% 98% 98% 99%
C++ g++

g++ (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609

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)