The Computer Language
24.11 Benchmarks Game

C++ g++ versus Go 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
Go #3 8.34 19,808 975 33.31
C++ g++ #4 8.92 19,760 1445 35.00
C++ g++ #2 9.13 19,760 1446 35.73
C++ g++ #3 37.88 19,760 600 37.87
C++ g++ 10.49 19,760 1065 41.21
Go #8 46.13 19,440 500 46.24
Go 12.29 19,808 906 49.04
Go #2 12.35 19,808 903 49.32
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
Go #3 6.38 19,808 1207 6.40
C++ g++ 6.61 19,760 1666 6.61
C++ g++ #6 6.93 19,760 1674 6.93
Go 7.01 19,808 1316 7.03
Go #2 7.03 19,808 1222 7.05
Go #8 9.60 19,436 1224 9.62
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
Go #8 5.33 19,416 429 5.34
Go 5.33 19,808 417 5.34
Go #2 1.50 19,808 674 5.68
Go #4 1.45 19,808 555 5.69
C++ g++ #7 1.52 19,512 1284 6.04
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
Go #4 3.76 35,456 912 14.99
Go #3 3.77 35,456 900 15.00
C++ g++ #2 16.95 34,636 700 16.94
Go 5.02 33,024 829 20.02
Go #8 26.68 19,440 500 26.74
Go #2 6.85 33,152 843 27.28
C++ g++ #3 27.37 19,760 421 27.36
Go #6 6.89 33,024 707 27.44
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
C++ g++ #5 1.06 19,760 2345 3.66
Go 3.73 19,808 1055 3.74
C++ g++ #6 1.07 19,760 2326 4.01
Go #2 1.27 19,808 1405 4.06
Go #3 1.51 19,808 1362 4.09
Go #8 18.27 19,440 838 18.46
k-nucleotide
source secs mem gz cpu secs
C++ g++ #2 2.01 156,592 1634 5.98
C++ g++ #3 4.19 165,580 1280 13.94
C++ g++ 6.96 757,156 1452 14.75
Go #7 7.63 163,072 1613 28.79
Go #3 8.18 145,280 1729 29.88
Go #6 8.21 145,152 1596 30.01
Go #4 9.16 140,032 1552 31.38
reverse-complement
source secs mem gz cpu secs
* C++ g++ #2 0.74 499,916 2099 0.74
Go #2 2.19 800,640 614 2.29
Go #3 2.48 800,384 609 2.57
Go #6 1.91 1,244,508 1340 3.40
C++ g++ #6 3.30 1,517,824 1827 4.38
C++ g++ 6.52 980,156 599 6.51
C++ g++ #5 37.59 771,632 704 37.58
Go #5   Bad Output  
Go   Failed  
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
C++ g++ 2.65 2,153,044 760 9.23
C++ g++ #2 22.83 265,840 514 22.82
Go #6 27.90 404,096 618 29.26
Go #2 14.17 624,780 672 56.29
Go #3 14.91 326,508 806 58.00
Go #5 14.87 425,960 957 58.15
Go 32.01 243,192 488 59.78
Go #7 32.52 248,604 531 61.47
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
* Go #4 0.82 19,808 689 0.83
Go 1.18 19,808 715 1.20
* Go #3 1.40 19,808 610 1.44
Go #2 1.84 19,808 740 1.89
Go #6 2.46 19,512 727 2.46
Go #7 4.99 19,808 702 5.61
regex-redux
source secs mem gz cpu secs
C++ g++ #6 1.15 276,336 2856 2.24
Go #5 3.25 321,360 817 5.43
C++ g++ #3 12.38 215,640 859 17.95
Go #4 14.61 369,008 832 35.91
Go 25.37 319,956 749 61.07
Go #3 25.62 371,204 836 61.79
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

Go

go version go1.23.1 linux/amd64
GOAMD64=v2