The Computer Language
24.09 Benchmarks Game

Java versus C++ g++ fastest performance

How the programs are written matters! Always look at the source code.

If the fastest programs are hand-written vector instructions, does the host language matter? You might be more interested in the less optimised programs — more seconds, less gz source code.

fannkuch-redux
source secs mem gz cpu secs
C++ g++ #6 3.26 19,712 1535 12.91
C++ g++ #7 13.96 19,712 1156 13.96
C++ g++ #5 8.00 19,712 987 31.23
C++ g++ #4 9.26 19,688 1445 36.31
C++ g++ #3 36.90 19,688 600 36.90
C++ g++ #2 9.55 19,712 1446 37.53
Java 10.04 42,708 1289 39.47
Java #3 40.81 42,920 1264 40.91
C++ g++ 10.87 19,712 1065 42.73
Java #2 44.33 41,012 520 44.38
n-body
source secs mem gz cpu secs
C++ g++ #0 2.15 19,736 1933 2.15
C++ g++ #7 3.96 19,736 1815 3.96
C++ g++ #2 4.20 19,736 1884 4.20
C++ g++ #3 5.31 19,736 1402 5.31
C++ g++ #9 5.44 19,736 1536 5.44
C++ g++ #4 5.45 19,736 1434 5.45
C++ g++ #5 6.02 19,736 1544 6.01
C++ g++ 6.50 19,736 1666 6.50
C++ g++ #8 6.54 19,736 1524 6.54
Java #5 6.79 41,476 1435 6.83
C++ g++ #6 6.91 19,736 1674 6.91
Java #4 6.91 41,364 1495 6.95
Java #2 7.58 41,440 1430 7.62
Java #3 7.63 41,352 1436 7.67
Java 7.89 41,616 1437 7.93
spectral-norm
source secs mem gz cpu secs
C++ g++ #6 0.72 19,884 1050 2.85
C++ g++ #5 1.33 19,788 1050 5.27
C++ g++ 5.37 19,852 459 5.37
C++ g++ #8 1.52 19,820 1284 6.06
Java #3 1.69 43,028 762 6.41
Java 7.08 42,384 521 7.14
Java #2 2.44 42,180 956 9.47
mandelbrot
source secs mem gz cpu secs
C++ g++ 0.89 34,944 1797 3.47
C++ g++ #4 0.89 35,328 3554 3.47
C++ g++ #6 0.98 35,072 1014 3.90
C++ g++ #0 2.36 35,456 2752 9.30
C++ g++ #8 4.84 34,944 749 13.21
C++ g++ #5 13.35 34,560 596 13.35
C++ g++ #9 3.50 35,072 732 13.49
C++ g++ #7 3.51 35,072 1023 13.94
Java #2 4.14 81,668 802 16.25
Java #4 4.44 104,696 667 16.25
C++ g++ #2 16.94 34,560 700 16.94
Java #6 4.31 81,888 808 16.97
Java 25.75 41,428 671 25.81
C++ g++ #3 27.27 19,736 421 27.27
Java #3 7.42 81,216 910 29.33
pidigits
source secs mem gz cpu secs
C++ g++ #5 0.87 19,736 804 0.87
C++ g++ #4 0.89 19,736 521 0.88
Java #3 0.94 40,944 770 0.96
Java #2 1.35 44,528 944 1.42
Java 7.63 491,600 807 8.66
regex-redux
source secs mem gz cpu secs
C++ g++ #6 1.18 276,148 2856 2.23
Java #8 1.62 372,312 2201 3.20
C++ g++ 3.56 212,180 662 3.56
C++ g++ #2 2.86 212,648 706 3.62
C++ g++ #5 3.81 215,648 859 4.53
Java 8.58 586,528 875 16.95
Java #6 5.59 1,235,356 746 17.14
Java #3 5.25 629,428 935 17.37
C++ g++ #3 12.46 215,472 859 18.08
C++ g++ #4   Make Error  
fasta
source secs mem gz cpu secs
C++ g++ #8 0.78 19,712 2758 1.54
C++ g++ #2 1.80 19,712 1129 1.80
C++ g++ 1.90 19,712 1064 1.90
C++ g++ #3 2.62 19,712 1311 2.62
Java #4 3.16 42,812 1528 3.27
C++ g++ #4 3.34 19,712 1291 3.34
C++ g++ #5 1.07 19,712 2345 3.67
Java #6 1.18 48,364 2549 3.74
C++ g++ #6 1.07 19,712 2326 3.85
Java #5 1.26 48,824 2478 4.17
Java #2 4.39 47,624 1259 4.56
C++ g++ #7   Make Error  
k-nucleotide
source secs mem gz cpu secs
C++ g++ #2 2.02 156,512 1634 6.09
C++ g++ #3 4.18 165,384 1280 13.93
C++ g++ 7.10 757,084 1452 14.78
Java 5.02 369,032 1821 16.31
Java #3 7.26 365,384 1642 25.09
Java #6 7.26 365,680 1614 25.28
Java #4 34.70 195,564 1887 35.08
Java #5 20.44 218,932 2225 44.56
reverse-complement
source secs mem gz cpu secs
C++ g++ #2 0.71 499,712 2099 0.71
Java #6 3.40 2,031,576 760 4.06
C++ g++ #6 3.26 1,517,580 1827 4.32
Java #5 4.78 1,096,264 1115 4.92
Java #4 5.59 1,890,020 656 5.71
Java #7 23.61 1,036,152 1654 6.24
C++ g++ 6.50 979,912 599 6.50
C++ g++ #5 36.24 771,432 704 36.24
Java #3   Bad Output  
C++ g++ #3   Bad Output  
Java #8   Bad Output  
binary-trees
source secs mem gz cpu secs
C++ g++ #7 0.96 201,536 896 3.35
C++ g++ #5 1.15 200,660 891 4.08
C++ g++ #9 1.65 136,064 815 4.55
C++ g++ #6 1.92 266,112 851 4.74
C++ g++ #3 2.25 265,600 951 5.11
Java #4 4.46 1,957,564 846 5.19
C++ g++ #8 2.22 266,112 826 5.26
Java #3 4.90 2,032,184 546 5.67
Java #6 5.02 2,065,280 535 5.79
Java #2 5.11 2,064,188 558 5.83
Java #7 2.59 1,718,620 841 8.08
C++ g++ 2.68 2,068,612 760 9.34
C++ g++ #2 21.96 265,856 514 21.96
C++ g++ #4   Make Error  
Java

java 22 2024-03-19
Java HotSpot(TM) 64-Bit Server VM
(build 22+36-2370,
mixed mode, sharing)

C++ g++

Ubuntu 13.2.0-23ubuntu4