The Computer Language
Benchmarks Game

Swift versus Rust fastest programs

Always look at the source code.

These are only the fastest programs. Do some of them use manually vectorized SIMD? Look at the other programs. They may seem more-like a fair comparison to you.

fannkuch-redux
source secs mem gz busy cpu load
Swift 8.24 7,824 1097 32.69 98% 99% 100% 100%
Rust 7.54 1,200 1020 29.78 97% 100% 99% 99%
pidigits
source secs mem gz busy cpu load
Swift 0.89 9,256 600 0.91 3% 0% 0% 99%
Rust 0.71 3,044 799 0.73 1% 0% 1% 100%
mandelbrot
source secs mem gz busy cpu load
Swift 1.34 41,120 1140 5.34 99% 99% 100% 100%
Rust 0.93 32,676 763 3.70 100% 99% 100% 100%
n-body
source secs mem gz busy cpu load
Swift 5.32 10,456 1365 5.37 100% 0% 0% 0%
Rust 3.29 1,196 1753 3.33 0% 100% 1% 0%
fasta
source secs mem gz busy cpu load
Swift 1.41 26,396 2090 4.73 80% 80% 96% 79%
Rust 0.77 1,840 2529 1.59 66% 100% 4% 38%
spectral-norm
source secs mem gz busy cpu load
Swift 1.43 8,144 601 5.68 100% 99% 99% 99%
Rust 0.72 2,672 1055 2.86 100% 100% 100% 99%
reverse-complement
source secs mem gz busy cpu load
Swift 1.81 781,992 1286 2.28 3% 0% 48% 75%
Rust 0.45 498,964 3040 0.77 25% 23% 100% 25%
k-nucleotide
source secs mem gz busy cpu load
Swift 13.56 256,964 1367 52.30 96% 95% 96% 99%
Rust 2.70 159,048 1691 10.08 93% 92% 91% 99%
binary-trees
source secs mem gz busy cpu load
Swift 16.15 699,872 862 51.81 77% 66% 79% 100%
Rust 1.09 198,728 765 3.90 87% 98% 88% 86%
regex-redux
source secs mem gz busy cpu load
Swift 23.14 1,059,096 745 48.76 92% 37% 46% 36%
Rust 0.77 147,524 2458 1.99 54% 59% 91% 54%
Swift

Swift version 5.5-dev (LLVM f9e846e117057c8, Swift a58e8c181f2e258)
Target: x86_64-unknown-linux-gnu

Rust

rustc 1.55.0 (c8dfcfe04 2021-09-06)
LLVM version: 12.0.1