The Computer Language
24.11 Benchmarks Game

C++ g++ versus Java GraalVM 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.31 19,760 1535 13.11
* C++ g++ #7 14.03 19,760 1156 14.03
C++ g++ #5 7.85 19,760 987 30.68
Java GraalVM #3 34.03 90,752 1264 34.21
C++ g++ #4 8.92 19,760 1445 35.00
C++ g++ #2 9.13 19,760 1446 35.73
Java GraalVM 9.33 91,152 1289 36.72
C++ g++ #3 37.88 19,760 600 37.87
Java GraalVM #2 38.48 91,636 520 38.63
C++ g++ 10.49 19,760 1065 41.21
Java GraalVM #8 42.18 91,368 517 42.35
n-body
source secs mem gz cpu secs
* C++ g++ #0 2.15 19,760 1933 2.15
* C++ g++ #7 4.11 19,760 1815 4.11
C++ g++ #9 5.14 19,760 1536 5.14
C++ g++ #3 5.32 19,760 1402 5.32
* C++ g++ #4 5.45 19,760 1434 5.45
* C++ g++ #2 6.02 19,352 1524 6.01
C++ g++ #5 6.32 19,760 1544 6.32
Java GraalVM #4 6.22 90,128 1495 6.36
C++ g++ 6.61 19,760 1666 6.61
Java GraalVM #5 6.47 90,344 1435 6.61
C++ g++ #6 6.93 19,760 1674 6.93
Java GraalVM #3 6.89 89,592 1436 7.03
Java GraalVM #2 6.90 89,600 1430 7.03
Java GraalVM #8 7.11 88,832 1322 7.24
Java GraalVM 7.31 89,724 1437 7.44
spectral-norm
source secs mem gz cpu secs
* C++ g++ #6 0.73 19,760 1050 2.86
* C++ g++ #5 1.33 19,760 1050 5.28
C++ g++ 5.33 19,760 459 5.33
C++ g++ #7 1.52 19,512 1284 6.04
Java GraalVM #3 1.64 92,416 762 6.14
Java GraalVM #2 1.80 92,800 956 6.83
Java GraalVM #8 11.19 91,648 453 11.38
mandelbrot
source secs mem gz cpu secs
* C++ g++ #4 0.89 35,344 3554 3.45
* C++ g++ 0.89 34,952 1797 3.47
* C++ g++ #6 0.98 35,080 1014 3.87
C++ g++ #0 2.35 35,476 2752 9.30
* C++ g++ #7 4.86 35,176 749 13.28
C++ g++ #5 13.44 34,636 596 13.43
C++ g++ #9 3.52 35,120 732 13.55
Java GraalVM #4 4.37 138,740 667 16.04
Java GraalVM #2 4.14 132,372 802 16.30
Java GraalVM #6 4.16 129,024 808 16.36
C++ g++ #2 16.95 34,636 700 16.94
Java GraalVM 26.60 90,356 671 26.78
C++ g++ #3 27.37 19,760 421 27.36
Java GraalVM #3 7.27 127,788 910 28.79
Java GraalVM #8 29.95 93,304 441 30.20
fasta
source secs mem gz cpu secs
C++ g++ #9 0.78 19,352 2758 1.54
C++ g++ #2 1.84 19,760 1129 1.84
C++ g++ 1.92 19,760 1064 1.92
C++ g++ #3 2.63 19,760 1311 2.63
C++ g++ #7 0.87 19,760 2711 3.05
C++ g++ #4 3.32 19,760 1291 3.32
Java GraalVM #6 1.28 99,840 2549 3.66
C++ g++ #5 1.06 19,760 2345 3.66
Java GraalVM #5 1.27 97,536 2478 3.75
C++ g++ #6 1.07 19,760 2326 4.01
Java GraalVM #4 3.55 142,080 1528 4.56
Java GraalVM #2 4.63 142,480 1259 5.61
Java GraalVM #8 9.75 181,036 894 10.30
k-nucleotide
source secs mem gz cpu secs
C++ g++ #2 2.01 156,592 1634 5.98
Java GraalVM 4.31 475,296 1821 13.63
C++ g++ #3 4.19 165,580 1280 13.94
C++ g++ 6.96 757,156 1452 14.75
Java GraalVM #6 7.69 471,456 1614 27.24
Java GraalVM #3 7.79 472,096 1642 27.63
Java GraalVM #4 33.45 239,724 1887 34.10
Java GraalVM #5 15.99 248,224 2225 38.12
Java GraalVM #8 84.32 1,586,392 786 87.17
reverse-complement
source secs mem gz cpu secs
* C++ g++ #2 0.74 499,916 2099 0.74
Java GraalVM #6 3.44 2,080,968 760 4.23
C++ g++ #6 3.30 1,517,824 1827 4.38
Java GraalVM #5 4.95 1,145,720 1115 5.31
Java GraalVM #4 5.69 1,906,560 656 5.99
C++ g++ 6.52 980,156 599 6.51
Java GraalVM #7 24.65 1,180,012 1654 12.56
C++ g++ #5 37.59 771,632 704 37.58
Java GraalVM #3   Bad Output  
C++ g++ #3   Bad Output  
binary-trees
source secs mem gz cpu secs
C++ g++ #7 0.97 201,512 896 3.40
C++ g++ #5 1.16 200,724 891 4.10
C++ g++ #9 1.74 136,120 815 4.63
C++ g++ #3 1.91 265,636 951 4.74
C++ g++ #6 1.91 266,120 851 4.77
C++ g++ #4 2.22 266,136 826 5.20
Java GraalVM #2 5.11 1,948,200 558 6.99
Java GraalVM #4 5.42 1,815,132 846 7.22
Java GraalVM #6 6.00 1,794,592 535 7.91
Java GraalVM #3 5.95 1,880,164 546 8.60
Java GraalVM #7 2.81 1,850,008 841 8.76
Java GraalVM #8 7.19 1,757,812 596 9.15
C++ g++ 2.65 2,153,044 760 9.23
C++ g++ #2 22.83 265,840 514 22.82
pidigits
source secs mem gz cpu secs
C++ g++ #4 0.71 19,760 521 0.71
* C++ g++ #5 0.73 19,760 804 0.73
Java GraalVM #3 0.84 87,552 770 0.96
Java GraalVM #2 1.34 96,384 944 1.53
Java GraalVM 7.08 528,896 807 8.13
regex-redux
source secs mem gz cpu secs
C++ g++ #6 1.15 276,336 2856 2.24
Java GraalVM #2 1.56 408,236 2201 3.36
Java GraalVM 7.95 617,884 875 15.48
Java GraalVM #3 4.93 646,312 935 16.03
Java GraalVM #6 5.21 1,281,824 746 16.40
C++ g++ #3 12.38 215,640 859 17.95
C++ g++   Make Error  
C++ g++ #2   Make Error  
C++ g++ #5   Make Error  
C++ g++ #4   Make Error  
C++ g++

g++ (Ubuntu 14.2.0-4ubuntu2) 14.2.0

Java GraalVM

openjdk 23 2024-09-17
Java HotSpot(TM) 64-Bit Server VM
OpenJDK GraalVM CE
(build 23+37-jvmci-b01,
mixed mode, sharing)