The Computer Language
Benchmarks Game

Rust versus C gcc fastest programs

Back in April 2010, Russ Cox charitably suggested that only fannkuch-redux, fasta, k-nucleotide, mandlebrot, nbody, reverse-complement and spectral-norm were close to fair comparisons. As someone who implemented programming languages, his interest was "measuring the quality of the generated code when both compilers are presented with what amounts to the same program."

Differences in approach - to memory management, parallel programming, regex, arbitrary precision arithmetic, implementation technique - don't fit in that kind-of fair comparison — but we still have to deal with them.

These are only the fastest programs. There may be additional measurements for programs which seem more-like a fair comparison to you. Always look at the source code.

n-body
source secs mem gz busy cpu load
Rust 6.07 944 1753 6.14 0% 0% 100% 1%
C gcc 7.30 8 1391 7.37 0% 0% 100% 1%
k-nucleotide
source secs mem gz busy cpu load
Rust 5.40 135,184 1749 17.13 60% 92% 69% 96%
C gcc 6.00 130,132 1506 18.48 70% 95% 89% 53%
binary-trees
source secs mem gz busy cpu load
Rust 3.33 199,664 721 12.08 87% 100% 88% 87%
C gcc 3.53 168,844 809 11.76 98% 75% 86% 74%
spectral-norm
source secs mem gz busy cpu load
Rust 1.97 2,196 1126 7.87 100% 100% 99% 99%
C gcc 1.98 1,224 569 7.88 99% 99% 99% 100%
pidigits
source secs mem gz busy cpu load
Rust 1.75 3,052 1366 1.78 1% 0% 1% 100%
C gcc 1.75 2,812 452 1.79 100% 0% 2% 1%
fasta
source secs mem gz busy cpu load
Rust 1.51 2,044 1906 4.60 74% 83% 73% 74%
C gcc 1.46 2,992 2268 5.81 99% 99% 99% 99%
mandelbrot
source secs mem gz busy cpu load
Rust 1.70 30,492 1332 6.70 98% 98% 98% 100%
C gcc 1.64 26,504 1135 6.54 100% 100% 99% 100%
reverse-complement
source secs mem gz busy cpu load
Rust 2.21 995,040 1871 3.10 1% 48% 24% 67%
C gcc 1.90 533,424 820 2.58 6% 20% 10% 99%
fannkuch-redux
source secs mem gz busy cpu load
Rust 10.62 944 1016 41.73 100% 93% 100% 100%
C gcc 8.75 948 910 34.50 100% 100% 100% 95%
regex-redux
source secs mem gz busy cpu load
Rust 2.10 153,076 986 3.14 30% 17% 83% 19%
C gcc 1.48 152,188 1397 3.44 46% 45% 100% 41%
Rust

rustc 1.39.0 (4560ea788 2019-11-04)
LLVM version: 9.0

C gcc

gcc (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008