The Computer Language
Benchmarks Game

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

regex-redux
source secs mem gz busy cpu load
C gcc 1.46 152,236 1397 3.43 43% 100% 45% 48%
Rust 2.12 153,184 986 3.15 15% 33% 85% 15%
fannkuch-redux
source secs mem gz busy cpu load
C gcc 8.61 880 910 33.96 95% 100% 99% 100%
Rust 11.13 876 1020 43.78 99% 95% 100% 100%
fasta
source secs mem gz busy cpu load
C gcc 1.36 2,912 2268 5.42 99% 100% 99% 99%
Rust 1.51 2,036 1961 4.60 83% 74% 73% 75%
k-nucleotide
source secs mem gz busy cpu load
C gcc 5.01 130,104 1506 16.41 84% 100% 84% 59%
Rust 5.17 134,552 1841 15.74 71% 91% 63% 80%
mandelbrot
source secs mem gz busy cpu load
C gcc 1.65 26,204 1135 6.56 99% 100% 99% 99%
Rust 1.70 30,424 1332 6.69 98% 98% 98% 99%
spectral-norm
source secs mem gz busy cpu load
C gcc 1.98 1,252 1139 7.88 99% 100% 99% 99%
Rust 1.98 2,156 1126 7.93 100% 100% 100% 99%
pidigits
source secs mem gz busy cpu load
C gcc 1.75 2,660 452 2.02 1% 100% 14% 1%
Rust 1.75 2,980 1366 1.78 0% 1% 1% 100%
binary-trees
source secs mem gz busy cpu load
C gcc 3.48 168,744 809 11.47 99% 74% 79% 79%
Rust 3.37 199,768 721 12.27 88% 88% 100% 88%
reverse-complement
source secs mem gz busy cpu load
C gcc 1.78 994,532 1438 4.02 42% 96% 46% 43%
Rust 1.62 994,820 1376 2.84 25% 26% 24% 100%
n-body
source secs mem gz busy cpu load
C gcc 7.49 8 1391 7.56 0% 0% 100% 1%
Rust 6.07 940 1753 6.14 1% 100% 0% 0%
C gcc

gcc (Ubuntu 8.3.0-6ubuntu1) 8.3.0

Rust

rustc 1.38.0 (625451e37 2019-09-23)
LLVM version: 9.0