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.

regex-redux
source secs mem gz busy cpu load
Rust 0.77 147,384 2458 2.00 55% 59% 55% 91%
C++ g++ 1.10 203,924 1315 3.43 63% 77% 71% 100%
reverse-complement
source secs mem gz busy cpu load
Rust 0.45 498,880 3040 0.76 61% 23% 60% 24%
C++ g++ 0.52 1,788 1853 0.52 0% 98% 0% 2%
spectral-norm
source secs mem gz busy cpu load
Rust 0.71 2,660 817 2.86 100% 100% 100% 100%
C++ g++ 0.72 1,192 1044 2.85 99% 99% 100% 100%
fasta
source secs mem gz busy cpu load
Rust 0.76 1,836 2529 1.53 99% 63% 38% 0%
C++ g++ 0.77 2,504 2751 1.52 64% 0% 99% 37%
binary-trees
source secs mem gz busy cpu load
Rust 1.02 198,720 765 3.64 87% 86% 85% 99%
C++ g++ 0.94 176,428 1122 3.39 86% 88% 100% 85%
pidigits
source secs mem gz busy cpu load
Rust 0.72 2,660 799 0.77 100% 0% 0% 7%
C++ g++ 0.66 5,152 986 2.63 100% 100% 100% 100%
mandelbrot
source secs mem gz busy cpu load
Rust 0.93 32,648 763 3.70 99% 100% 100% 100%
C++ g++ 0.84 34,780 3542 3.27 99% 98% 98% 96%
k-nucleotide
source secs mem gz busy cpu load
Rust 2.68 159,104 1691 10.03 92% 91% 100% 91%
C++ g++ 1.93 156,548 1631 5.88 69% 93% 69% 75%
n-body
source secs mem gz busy cpu load
Rust 3.42 872 1753 3.44 0% 100% 0% 0%
C++ g++ 2.12 764 1927 2.17 0% 2% 100% 0%
fannkuch-redux
source secs mem gz busy cpu load
Rust 7.61 1,200 1020 29.86 94% 100% 99% 99%
C++ g++ 3.29 1,892 1528 13.06 100% 100% 100% 97%
Rust

rustc 1.53.0 (53cb7b09b 2021-06-17)
LLVM version: 12.0.1

C++ g++

g++ (Ubuntu 10.3.0-1ubuntu1) 10.3.0