The Computer Language
Benchmarks Game

Rust versus C++ g++ 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.

reverse-complement
source secs mem gz busy cpu load
Rust 0.45 499,100 3040 0.78 23% 24% 64% 61%
C++ g++ 0.63 499,704 2093 0.64 0% 100% 2% 0%
regex-redux
source secs mem gz busy cpu load
Rust 0.79 143,672 2458 1.99 53% 59% 52% 90%
C++ g++ 1.08 203,816 1315 3.38 78% 99% 65% 73%
n-body
source secs mem gz busy cpu load
Rust 3.32 844 1767 3.43 100% 3% 0% 0%
C++ g++ 4.09 1,740 1808 4.26 100% 0% 3% 0%
fasta
source secs mem gz busy cpu load
Rust 0.77 1,884 2529 1.53 0% 1% 99% 99%
C++ g++ 0.78 2,468 2751 1.62 8% 99% 99% 3%
spectral-norm
source secs mem gz busy cpu load
Rust 0.71 2,668 1055 2.85 100% 100% 99% 100%
C++ g++ 0.72 1,216 1044 2.86 100% 100% 99% 100%
binary-trees
source secs mem gz busy cpu load
Rust 1.04 198,844 765 3.74 87% 86% 87% 100%
C++ g++ 1.04 154,824 1122 3.74 88% 100% 88% 86%
mandelbrot
source secs mem gz busy cpu load
Rust 0.92 32,588 763 3.67 99% 100% 100% 100%
C++ g++ 0.84 34,604 3542 3.28 98% 99% 98% 95%
pidigits
source secs mem gz busy cpu load
Rust 0.71 2,912 799 0.72 0% 100% 1% 0%
C++ g++ 0.60 4,944 986 2.38 100% 100% 98% 100%
k-nucleotide
source secs mem gz busy cpu load
Rust 2.75 159,068 1691 10.20 99% 90% 91% 91%
C++ g++ 1.95 156,372 1631 5.95 73% 70% 92% 70%
fannkuch-redux
source secs mem gz busy cpu load
Rust 7.13 1,176 1020 28.07 99% 95% 100% 99%
C++ g++ 4.91 1,912 1482 19.45 100% 99% 97% 100%
Rust

rustc 1.51.0 (2fd73fabe 2021-03-23)
LLVM version: 11.0.1

C++ g++

g++ (Ubuntu 10.2.0-13ubuntu1) 10.2.0