The Computer Language
24.11 Benchmarks Game

Rust versus C clang fastest performance

How the programs are written matters! Always look at the source code.

If the fastest programs are * hand-written vector instructions, does the host language matter? You might be more interested in the less optimised programs — more seconds, less gz source code.

fannkuch-redux
source secs mem gz cpu secs
* C clang #6 2.24 19,772 1582 8.86
* C clang #4 13.37 19,772 1190 13.37
* Rust #6 3.86 19,684 1260 15.17
Rust #4 6.92 19,684 1026 27.13
Rust #5 7.45 19,684 1023 29.32
C clang #5 8.09 19,772 917 31.94
* C clang #2 8.67 19,772 1563 34.02
C clang #3 34.16 19,772 574 34.15
Rust #2 9.15 19,684 1198 35.91
C clang #8 36.39 19,492 483 36.38
C clang 36.51 19,772 514 36.50
n-body
source secs mem gz cpu secs
* Rust #9 2.19 19,624 1881 2.19
* C clang #9 2.20 19,772 1639 2.20
* Rust #7 3.23 19,624 1759 3.23
Rust #3 3.46 19,624 1774 3.45
Rust #2 3.64 19,624 1809 3.64
* Rust #6 4.36 19,624 1796 4.35
* C clang #5 4.86 19,772 1436 4.86
* Rust #5 5.01 19,624 2224 5.01
Rust #4 5.11 19,624 1810 5.11
C clang #6 5.16 19,772 1186 5.16
C clang 5.37 19,772 1179 5.37
C clang #2 5.42 19,772 1270 5.42
Rust 5.52 19,624 1483 5.52
* C clang #4 5.60 19,772 1398 5.59
C clang #8 5.72 19,492 1193 5.72
C clang #3 6.12 19,772 1214 6.12
C clang #7 6.77 19,772 1250 6.77
spectral-norm
source secs mem gz cpu secs
* C clang #6 0.38 19,772 1203 1.52
* Rust 0.72 19,632 1262 2.80
* Rust #2 0.72 19,632 1117 2.80
Rust #4 0.72 19,632 823 2.85
* Rust #5 0.72 19,632 1062 2.85
* Rust #6 0.72 19,632 1132 2.85
* Rust #3 0.74 19,632 1060 2.86
* C clang #4 0.72 19,772 1145 2.86
* C clang #2 0.72 19,772 941 2.87
* C clang #5 0.72 19,772 576 2.88
C clang #8 5.40 19,772 389 5.40
C clang #3 1.46 19,772 470 5.77
* C clang #7 1.82 19,772 906 7.24
* Rust #7   Make Error  
mandelbrot
source secs mem gz cpu secs
* Rust #4 0.95 33,392 1301 3.77
* Rust #6 1.07 34,152 1338 4.20
Rust #2 1.09 33,384 770 4.33
Rust #7 1.10 33,380 763 4.37
Rust #5 1.11 33,956 725 4.37
Rust #3 1.14 19,624 1013 4.54
C clang #9 1.22 34,332 700 4.85
C clang #5 1.53 34,864 788 6.09
Rust 2.00 39,404 874 7.88
* C clang #4 3.47 34,328 805 13.82
* C clang 3.49 33,172 828 13.93
* C clang #7 3.53 34,216 1000 14.00
* C clang #3 3.55 33,108 769 14.15
C clang #8 25.27 19,496 412 25.27
* C clang #6   Make Error  
fasta
source secs mem gz cpu secs
C clang #3 0.78 19,772 1469 0.78
C clang #5 1.20 19,772 1286 1.20
* Rust #7 0.77 19,624 2533 1.54
Rust #3 1.98 19,624 1235 1.98
C clang #2 2.43 19,616 1299 2.43
C clang #6 1.03 19,772 1936 3.03
Rust #9 0.94 19,624 1952 3.22
C clang #7 0.82 19,772 2276 3.27
Rust #5 0.93 19,624 1963 3.34
Rust #2 0.92 19,624 1910 3.40
Rust #6 3.46 123,848 959 3.46
C clang 3.46 19,772 1213 3.46
Rust #4 3.47 123,848 944 3.46
Rust 4.25 19,624 1240 4.25
C clang #8 8.02 19,956 839 8.02
C clang #4   Make Error  
k-nucleotide
source secs mem gz cpu secs
Rust #7 2.67 133,824 1585 8.21
Rust #3 3.21 137,564 1549 9.51
Rust #6 2.80 159,764 1697 10.03
Rust #5 3.82 137,924 1745 11.17
C clang 6.30 129,228 1512 13.92
Rust #2 5.87 138,292 1350 15.32
Rust #9 6.63 136,168 1850 17.12
Rust #4 6.73 137,308 1755 18.72
Rust 21.46 157,492 1086 66.75
reverse-complement
source secs mem gz cpu secs
* C clang #7 0.45 499,996 1899 0.63
C clang #9 0.46 499,976 1551 0.70
* Rust 0.53 498,952 2762 0.84
Rust #2 0.95 995,220 1332 1.58
C clang #2 1.16 994,536 757 1.69
Rust #3 0.97 995,156 1105 1.69
C clang #5 2.08 994,108 654 2.07
* C clang #4 3.74 500,452 716 3.74
C clang #6 1.03 703,416 828 4.07
binary-trees
source secs mem gz cpu secs
Rust #5 1.09 198,720 771 3.84
Rust #2 1.19 199,796 729 4.21
Rust #3 1.39 189,928 762 5.00
Rust #4 1.39 199,084 765 5.01
C clang #2 1.66 170,236 816 5.36
C clang #3 1.89 134,272 842 5.88
Rust 2.04 132,952 760 7.26
C clang 17.79 264,064 660 17.79
C clang #8 19.63 285,536 607 19.62
C clang #5 9.25 351,328 914 33.65
pidigits
source secs mem gz cpu secs
Rust #4 0.71 19,624 804 0.71
C clang #2 0.74 19,772 422 0.74
* Rust #3 0.74 19,624 1373 0.74
* Rust #2 0.74 19,624 1312 0.74
C clang 0.74 19,772 459 0.74
* Rust 0.74 19,624 1426 0.74
regex-redux
source secs mem gz cpu secs
Rust #6 1.17 153,780 994 1.42
Rust 1.34 153,972 811 1.56
Rust #5 1.33 202,800 777 1.57
Rust #4 1.34 199,684 771 1.58
Rust #3 1.34 202,952 726 1.59
Rust #2 1.38 153,932 707 1.63
* Rust #7 0.78 148,924 2464 2.00
C clang #5 0.82 154,568 1403 2.82
C clang #2 3.22 103,364 1121 3.22
C clang #4 0.98 154,488 1237 3.82
C clang #3 1.75 105,848 1273 4.31
Rust

1.83.0
(90b35a623
2024-11-26)
LLVM version: 19.1.1

C clang

Ubuntu clang version 18.1.8 (11)