The Computer Language
Benchmarks Game

Java versus C++ g++ fastest programs

by faster benchmark performance

reverse-complement
source secs mem gz cpu cpu load
Java 3.31 626,956 2183 7.44 56% 60% 83% 45%
C++ g++ 2.95 980,472 2280 4.56 50% 41% 16% 50%
pidigits
source secs mem gz cpu cpu load
Java 3.13 37,324 938 3.35 98% 5% 3% 3%
C++ g++ 1.89 4,284 513 1.88 5% 0% 1% 100%
fannkuch-redux
source secs mem gz cpu cpu load
Java 17.91 31,560 1282 70.25 99% 98% 99% 97%
C++ g++ 10.62 2,040 980 41.91 100% 95% 100% 100%
fasta
source secs mem gz cpu cpu load
Java 2.32 42,556 2473 6.24 73% 85% 49% 63%
C++ g++ 1.33 1,956 2711 4.16 79% 79% 79% 79%
spectral-norm
source secs mem gz cpu cpu load
Java 4.27 32,960 950 16.41 95% 97% 98% 96%
C++ g++ 1.98 1,340 1044 7.87 99% 100% 99% 99%
k-nucleotide
source secs mem gz cpu cpu load
Java 8.66 385,768 1812 26.52 76% 81% 74% 76%
C++ g++ 3.66 155,956 1624 11.16 70% 98% 70% 68%
n-body
source secs mem gz cpu cpu load
Java 22.00 32,496 1489 22.07 1% 100% 0% 1%
C++ g++ 8.24 1,924 1763 8.23 1% 0% 100% 1%
binary-trees
source secs mem gz cpu cpu load
Java 8.28 982,224 835 27.19 79% 86% 83% 83%
C++ g++ 2.63 130,600 809 7.93 98% 68% 62% 76%
mandelbrot
source secs mem gz cpu cpu load
Java 6.96 76,748 796 27.07 98% 98% 96% 98%
C++ g++ 1.51 25,588 1791 5.99 99% 99% 99% 99%
regex-redux
source secs mem gz cpu cpu load
Java 10.52 637,380 929 31.89 75% 80% 77% 72%
C++ g++ 1.66 203,568 1315 4.23 48% 53% 57% 99%
Java

openjdk 11 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)

C++ g++

g++ (Ubuntu 7.3.0-16ubuntu3) 7.3.0