The Computer Language
22.01 Benchmarks Game

Swift versus Rust fastest programs

Always look at the source code. These are only the fastest programs.

If they are manually vectorized SIMD, does the host language matter? You might not be interested in the most optimised programs.

Look at "mandelbrot" or "spectral-norm" or other measurement tables. Look at the other programs. Choose which programs you want to compare.

pidigits
source secs mem gz busy cpu load
Swift 0.74 7,904 600 0.83 3% 3% 100% 7%
Rust 0.70 2,580 799 0.70 0% 100% 0% 0%
mandelbrot
source secs mem gz busy cpu load
Swift 1.36 41,876 1140 5.44 100% 99% 100% 99%
Rust 0.91 32,676 757 3.63 100% 99% 99% 100%
n-body
source secs mem gz busy cpu load
Swift 5.27 10,888 1326 5.29 100% 0% 0% 0%
Rust 2.90 1,052 1874 2.98 0% 1% 100% 1%
spectral-norm
source secs mem gz busy cpu load
Swift 1.43 6,736 601 5.70 100% 100% 100% 99%
Rust 0.71 2,488 932 2.85 100% 100% 99% 100%
fannkuch-redux
source secs mem gz busy cpu load
Swift 8.07 6,520 1097 31.99 98% 100% 98% 100%
Rust 3.80 1,352 1253 15.13 100% 99% 99% 99%
fasta
source secs mem gz busy cpu load
Swift 2.18 26,772 2090 8.01 93% 93% 92% 90%
Rust 0.77 1,996 2529 1.56 100% 1% 4% 99%
reverse-complement
source secs mem gz busy cpu load
Swift 1.79 769,116 1286 2.27 74% 4% 0% 48%
Rust 0.45 498,736 3040 0.78 26% 48% 76% 24%
k-nucleotide
source secs mem gz busy cpu load
Swift 13.82 257,204 1367 52.70 98% 95% 94% 95%
Rust 2.69 159,044 1691 10.00 92% 97% 92% 92%
binary-trees
source secs mem gz busy cpu load
Swift 16.52 700,384 816 52.80 75% 100% 77% 67%
Rust 1.11 198,404 765 3.93 86% 98% 86% 85%
regex-redux
source secs mem gz busy cpu load
Swift 22.85 1,060,884 745 48.62 37% 37% 47% 92%
Rust 0.78 146,632 2458 2.01 56% 60% 90% 53%
Swift

Swift version 5.6-dev (LLVM 031406b6cea8006, Swift 9f7d3fccad66d76)
Target: x86_64-unknown-linux-gnu

Rust

rustc 1.58.0 (02072b482 2022-01-11)
LLVM version: 13.0.0