The Computer Language
22.05 Benchmarks Game

Fastest cpu secs Swift versus Rust

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
Rust #6 1,372 1253 14.15
Rust #4 1,372 1020 30.06
Rust #3 1,336 1020 30.07
Rust #5 1,368 1016 30.11
Swift #3 6,644 1097 31.59
Swift 6,456 451 35.27
Rust #2 1,232 1191 72.42
n-body
source mem gz cpu
Rust #9 1,052 1874 2.89
Rust #7 1,052 1753 3.24
Rust #6 1,028 1790 4.05
Swift #4 14,076 1355 5.28
Swift #5 10,800 1365 5.29
Swift #7 14,024 1326 5.33
Rust #3 1,108 1540 5.49
Rust #2 1,032 1805 5.67
Rust 1,044 1480 5.68
Swift #8 14,028 1681 5.70
Rust #8 1,104 1767 5.78
Rust #5 1,104 2220 6.10
Swift #6 6,356 1194 6.11
Rust #4 1,088 1803 6.25
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
Rust #6 2,432 1126 2.84
Rust #5 2,560 1055 2.84
Rust #7 2,436 932 2.84
Rust #4 2,640 817 2.84
Rust #2 1,312 1110 2.87
Rust 1,276 1254 2.87
Rust #3 1,248 1053 2.98
Swift 12,872 438 5.32
Swift #3 6,876 601 5.68
mandelbrot
source mem gz cpu
Rust #6 33,872 1332 4.18
Swift #7 41,804 1140 5.29
Swift #6 44,504 1141 5.43
Rust #8 32,624 763 5.48
Rust #7 32,732 757 5.50
Rust #3 12,824 1007 5.52
Rust 38,672 868 6.87
Rust #5 33,948 719 10.40
Swift 6,484 394 26.22
Swift #5 41,620 659 26.91
Swift #3   Bad Output  
pidigits
source mem gz cpu
Rust #4 2,624 799 0.71
Rust #2 2,924 1306 0.74
Rust 2,928 1420 0.74
Swift #2 8,132 600 0.74
Rust #3 2,960 1366 0.83
regex-redux
source mem gz cpu
Rust #6 153,148 986 1.79
Rust #5 202,556 771 1.83
Rust 152,864 804 1.83
Rust #4 202,612 765 1.87
Rust #3 203,408 719 1.89
Rust #2 152,172 701 1.89
Rust #7 147,360 2458 1.99
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
Rust #7 2,052 2529 1.52
Rust #3 1,104 1233 2.03
Rust #5 2,580 1961 3.10
Swift #2 7,440 1945 3.17
Rust #2 2,580 1906 3.18
Rust #8 2,596 1946 3.55
Rust #4 123,860 939 3.57
Rust #6 123,848 955 3.58
Rust 1,100 1237 4.45
Swift 6,908 1526 4.52
Swift #3 26,916 2090 4.64
k-nucleotide
source mem gz cpu
Rust #7 131,236 1578 9.12
Rust #8 137,632 1543 10.39
Rust #6 159,088 1691 10.68
Rust #5 133,912 1739 12.23
Rust #2 137,896 1347 16.27
Rust #9 134,732 1841 18.77
Rust #4 136,216 1749 19.31
Swift #2 257,052 1367 52.46
Rust 152,220 1078 70.04
Swift   Make Error  
reverse-complement
source mem gz cpu
Rust 499,068 3040 0.76
Rust #2 995,032 1330 1.36
Rust #3 995,032 1097 1.52
Swift 794,484 1286 2.26
binary-trees
source mem gz cpu
Rust #5 198,536 765 3.60
Rust #2 200,024 721 4.17
Rust #4 181,444 756 4.40
Rust #3 163,904 754 4.87
Rust 132,604 751 7.70
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)

Rust

rustc 1.60.0
(7737e0b5c
2022-04-04)
LLVM version: 14.0.0