The Computer Language
22.05 Benchmarks Game

Fastest cpu secs Swift versus C gcc

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 cpu seconds, less gz source code.

fannkuch-redux
source mem gz cpu
C gcc #6 1,044 1576 8.26
C gcc #4 964 1183 13.89
C gcc #5 1,072 910 29.38
Swift #3 6,644 1097 31.59
Swift 6,456 451 35.27
C gcc #3 1,016 567 42.18
C gcc 988 508 43.27
C gcc #2 1,140 1557 45.01
n-body
source mem gz cpu
C gcc #9 992 1633 2.12
C gcc #8 8 1391 4.10
C gcc #4 1,304 1490 4.44
Swift #4 14,076 1355 5.28
Swift #5 10,800 1365 5.29
Swift #7 14,024 1326 5.33
Swift #8 14,028 1681 5.70
C gcc #5 1,020 1429 6.10
Swift #6 6,356 1194 6.11
C gcc #7 1,300 1244 6.79
C gcc #2 1,264 1263 7.19
C gcc #6 1,304 1180 7.21
C gcc #3 1,304 1208 7.23
C gcc 1,264 1173 7.55
Swift #3 6,452 1204 8.11
Swift #2 6,420 1192 8.68
Swift #9 14,032 1526 292.55
spectral-norm
source mem gz cpu
C gcc #6 1,068 1197 1.57
C gcc #5 1,344 569 2.85
C gcc #4 1,352 1139 2.85
Swift 12,872 438 5.32
C gcc 1,248 383 5.38
C gcc #3 1,348 463 5.68
Swift #3 6,876 601 5.68
mandelbrot
source mem gz cpu
C gcc #6 31,244 1135 5.12
Swift #7 41,804 1140 5.29
Swift #6 44,504 1141 5.43
C gcc #8 33,068 782 6.29
C gcc #4 32,704 799 13.81
C gcc #7 33,108 994 13.87
C gcc 29,692 822 13.91
C gcc #3 29,840 763 13.99
C gcc #9 32,904 694 16.03
C gcc #2 1,040 400 25.30
Swift 6,484 394 26.22
Swift #5 41,620 659 26.91
Swift #3   Bad Output  
pidigits
source mem gz cpu
C gcc 2,648 452 0.73
C gcc #2 2,920 416 0.74
Swift #2 8,132 600 0.74
regex-redux
source mem gz cpu
C gcc #5 152,220 1397 2.02
C gcc #2 103,084 1115 3.23
C gcc #4 152,056 1230 3.24
C gcc #3 103,540 1266 3.31
Swift #2 682,836 671 43.47
Swift 879,156 715 44.12
Swift #4 1,061,888 745 45.38
fasta
source mem gz cpu
C gcc #9 1,256 1463 0.78
C gcc #5 1,052 1281 1.30
C gcc #8 1,044 1293 2.74
C gcc #6 2,140 1930 2.76
C gcc #4 1,020 1240 3.06
Swift #2 7,440 1945 3.17
C gcc #2 2,860 2268 3.25
C gcc #7 2,864 2011 3.28
C gcc 1,016 1206 3.67
C gcc #3 972 819 4.49
Swift 6,908 1526 4.52
Swift #3 26,916 2090 4.64
k-nucleotide
source mem gz cpu
C gcc 130,156 1506 12.31
Swift #2 257,052 1367 52.46
Swift   Make Error  
reverse-complement
source mem gz cpu
C gcc #7 499,132 1965 0.57
C gcc #8 499,184 1627 0.77
C gcc #6 688,416 820 1.27
C gcc #5 994,088 647 1.42
C gcc #2 994,152 750 1.45
Swift 794,484 1286 2.26
C gcc #4 500,416 709 3.49
binary-trees
source mem gz cpu
C gcc #2 168,384 809 4.32
C gcc #3 134,068 836 4.71
C gcc 263,664 654 22.16
C gcc #5 351,304 908 32.02
Swift #5 733,388 806 41.37
Swift #3 700,092 862 43.45
Swift #2 699,876 816 44.09
Swift 733,908 714 59.11
Swift #4 700,512 765 60.93
Swift #9   Make Error  
Swift

Swift version 5.7-dev
(LLVM a177fc627109410,
Swift 31967c6df177cce)

C gcc

11.2.0-19ubuntu1