The Computer Language
24.04 Benchmarks Game

Swift versus Go fastest performance

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
Go #3 8.33 19,664 975 33.25
Swift 33.85 19,660 457 33.85
Swift #3 8.58 19,660 1103 33.96
Go 11.74 19,664 906 46.77
Go #2 11.79 19,664 903 46.97
n-body
source secs mem gz cpu secs
Swift #4 5.49 19,680 1361 5.49
Swift #5 5.51 19,812 1372 5.51
Swift #7 5.52 19,684 1333 5.52
Swift #6 5.97 19,680 1200 5.97
Swift #8 5.99 19,808 1688 5.99
Go #3 6.37 19,808 1207 6.38
Go 7.00 19,680 1316 7.02
Go #2 7.02 19,680 1222 7.03
Swift #2 9.55 19,684 1198 9.55
Swift #3 202.89 19,680 1210 202.89
Swift #9 287.28 19,684 1532 287.27
spectral-norm
source secs mem gz cpu secs
Swift 5.32 19,684 444 5.32
Go 5.32 19,824 417 5.33
Go #2 1.53 19,824 674 5.67
Go #4 1.44 19,824 555 5.67
Swift #3 1.43 19,684 607 5.69
mandelbrot
source secs mem gz cpu secs
Swift #7 1.34 47,104 1147 5.30
Swift #6 1.45 50,176 1147 5.73
Go #4 3.76 35,328 912 14.92
Go #3 3.76 35,456 900 14.94
Go 5.01 33,408 829 19.98
Swift 26.40 19,680 400 26.40
Swift #5 7.21 43,520 665 26.95
Go #2 6.85 33,152 843 27.29
Go #6 6.89 32,768 707 27.40
Swift #3   Bad Output  
pidigits
source secs mem gz cpu secs
Swift #2 0.88 19,684 606 0.88
Go #4 0.95 19,808 689 0.97
Go 1.35 19,696 715 1.37
Go #3 1.58 19,824 610 1.62
Go #2 2.13 19,824 740 2.19
Go #8 2.49 19,696 727 2.50
Go #7 5.12 19,824 702 5.88
regex-redux
source secs mem gz cpu secs
Go #5 3.17 320,972 817 5.38
Go #4 14.51 368,680 832 34.26
Swift #2 41.76 684,640 678 41.75
Swift 24.13 889,972 721 42.70
Swift #4 20.41 1,060,208 751 44.32
Go 25.58 345,472 749 61.95
Go #3 25.72 402,968 836 62.19
fasta
source secs mem gz cpu secs
Go 3.73 19,804 1055 3.74
Swift #2 2.18 19,680 1952 3.83
Go #2 1.26 19,672 1405 4.03
Go #3 1.50 19,664 1362 4.08
Swift 5.15 19,676 1533 5.15
Swift #3 2.14 29,584 2097 5.26
k-nucleotide
source secs mem gz cpu secs
Go #7 7.52 162,944 1613 28.68
Go #6 8.17 145,152 1596 29.90
Go #3 8.38 145,152 1729 30.32
Go #4 9.07 139,904 1552 30.33
Swift #2 14.51 259,048 1373 55.29
Swift   Make Error  
reverse-complement
source secs mem gz cpu secs
Go #2 2.21 802,176 614 2.30
Swift 1.88 796,840 1293 2.30
Go #3 2.47 802,048 609 2.56
Go #6 1.84 1,249,840 1340 3.30
Go #5   Bad Output  
Go   Failed  
binary-trees
source secs mem gz cpu secs
Go #6 27.61 404,608 618 29.03
Swift #5 13.79 736,000 813 40.99
Swift #3 13.33 705,408 868 43.00
Swift #2 13.28 705,280 822 43.28
Go #2 13.87 601,252 672 55.04
Go #5 14.37 308,092 957 56.80
Go #3 14.86 323,544 806 57.39
Go 30.97 262,396 488 57.95
Swift 20.15 735,488 720 59.68
Go #7 33.10 292,588 531 61.68
Swift #4 19.49 705,536 772 62.34
Swift #9   Make Error  
Swift

Swift version 5.10
(swift-5.10-RELEASE)

Go

go version go1.22.0 linux/amd64
GOAMD64=v2