The Computer Language
24.06 Benchmarks Game

Go 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
Go #3 8.36 19,656 975 33.34
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
C++ g++ 10.87 19,712 1065 42.73
Go 11.77 19,656 906 46.92
Go #2 11.83 19,656 903 47.16
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
Go #3 6.38 19,688 1207 6.39
C++ g++ 6.50 19,736 1666 6.50
C++ g++ #8 6.54 19,736 1524 6.54
C++ g++ #6 6.91 19,736 1674 6.91
Go 7.00 19,688 1316 7.02
Go #2 7.03 19,688 1222 7.04
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
Go 5.33 20,116 417 5.34
C++ g++ 5.37 19,852 459 5.37
Go #4 1.43 20,340 555 5.68
Go #2 1.50 20,148 674 5.69
C++ g++ #8 1.52 19,820 1284 6.06
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
Go #3 3.77 35,328 900 14.99
Go #4 3.77 35,328 912 15.00
C++ g++ #2 16.94 34,560 700 16.94
Go 5.01 33,024 829 19.93
C++ g++ #3 27.27 19,736 421 27.27
Go #2 6.86 33,152 843 27.28
Go #6 6.91 32,896 707 27.48
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
Go #4 0.96 19,700 689 0.98
Go 1.34 19,700 715 1.36
Go #3 1.65 19,700 610 1.69
Go #2 2.18 19,700 740 2.23
Go #8 2.51 19,700 727 2.51
Go #7 5.19 19,700 702 5.98
regex-redux
source secs mem gz cpu secs
C++ g++ #6 1.18 276,148 2856 2.23
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
Go #5 3.22 320,724 817 5.39
C++ g++ #3 12.46 215,472 859 18.08
Go #4 14.78 397,240 832 36.01
Go #3 25.54 370,524 836 61.42
Go 25.87 311,444 749 64.23
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
C++ g++ #4 3.34 19,712 1291 3.34
C++ g++ #5 1.07 19,712 2345 3.67
Go 3.74 19,664 1055 3.74
C++ g++ #6 1.07 19,712 2326 3.85
Go #2 1.27 19,664 1405 4.07
Go #3 1.50 19,664 1362 4.08
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
Go #7 7.53 162,816 1613 28.78
Go #6 8.26 145,152 1596 30.01
Go #3 8.29 145,152 1729 30.02
Go #4 9.22 139,776 1552 30.55
reverse-complement
source secs mem gz cpu secs
C++ g++ #2 0.71 499,712 2099 0.71
Go #2 2.24 800,512 614 2.34
Go #3 2.50 800,128 609 2.60
Go #6 1.93 1,246,404 1340 3.43
C++ g++ #6 3.26 1,517,580 1827 4.32
C++ g++ 6.50 979,912 599 6.50
C++ g++ #5 36.24 771,432 704 36.24
Go #5   Bad Output  
Go   Failed  
C++ g++ #3   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
C++ g++ #8 2.22 266,112 826 5.26
C++ g++ 2.68 2,068,612 760 9.34
C++ g++ #2 21.96 265,856 514 21.96
Go #6 27.68 404,224 618 29.07
Go #2 13.86 594,740 672 55.04
Go #5 14.29 317,028 957 56.60
Go #3 14.72 343,248 806 57.03
Go 31.84 237,200 488 59.20
Go #7 31.79 250,476 531 59.90
C++ g++ #4   Make Error  
Go

go version go1.22.3 linux/amd64
GOAMD64=v2

C++ g++

Ubuntu 13.2.0-23ubuntu4