The Computer Language
24.11 Benchmarks Game

Rust versus C gcc 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 gcc #6 2.14 19,704 1582 8.43
* C gcc #4 14.04 19,704 1190 14.03
* Rust #6 3.88 19,804 1260 15.27
Rust #4 6.93 19,804 1026 27.20
C gcc #5 7.29 19,704 917 28.25
Rust #5 7.66 19,804 1023 29.90
Rust #2 9.15 19,804 1198 35.90
C gcc #3 36.80 19,704 574 36.79
C gcc #8 39.33 19,492 483 39.32
C gcc 39.61 19,704 514 39.60
* C gcc #2 10.19 19,704 1563 39.99
n-body
source secs mem gz cpu secs
* C gcc #9 2.10 19,772 1639 2.10
* Rust #9 2.19 19,804 1881 2.19
* Rust #7 3.25 19,804 1759 3.24
Rust #2 3.94 19,804 1809 3.94
* C gcc #4 4.05 19,772 1398 4.05
* Rust #6 4.30 19,804 1796 4.30
Rust #3 4.49 19,352 1774 4.49
C gcc #6 4.97 19,772 1186 4.97
* Rust #5 5.01 19,804 2224 5.01
Rust #4 5.10 19,804 1810 5.10
C gcc #2 5.19 19,772 1270 5.19
C gcc #3 5.23 19,772 1214 5.23
C gcc 5.23 19,772 1179 5.23
* C gcc #5 5.43 19,772 1436 5.43
Rust 5.51 19,804 1483 5.51
C gcc #8 5.54 19,492 1193 5.54
C gcc #7 6.89 19,772 1250 6.88
spectral-norm
source secs mem gz cpu secs
* C gcc #6 0.40 19,772 1203 1.59
* Rust #6 0.72 19,804 1132 2.85
Rust #4 0.72 19,804 823 2.85
* Rust #5 0.72 19,804 1062 2.85
* C gcc #5 0.72 19,772 576 2.85
* C gcc #7 0.72 19,772 906 2.85
* C gcc #4 0.72 19,772 1145 2.85
* Rust #2 0.78 19,804 1117 2.98
* Rust 0.77 19,804 1262 2.99
* Rust #3 0.78 19,804 1060 3.00
C gcc #8 5.40 19,772 389 5.39
C gcc #3 1.43 19,772 470 5.70
* Rust #7   Make Error  
* C gcc #2   Make Error  
mandelbrot
source secs mem gz cpu secs
* Rust #4 0.94 33,408 1301 3.73
Rust #2 1.07 33,592 770 4.23
* Rust #6 1.08 34,048 1338 4.23
Rust #7 1.06 33,408 763 4.23
Rust #5 1.13 34,048 725 4.43
Rust #3 1.14 19,860 1013 4.54
* C gcc #6 1.28 33,400 1147 5.10
C gcc #5 1.63 33,512 788 6.31
Rust 2.00 39,296 874 7.84
* C gcc #4 3.52 33,060 805 13.89
* C gcc 3.49 32,864 828 13.92
* C gcc #7 3.51 33,276 1000 13.95
* C gcc #3 3.53 32,860 769 14.09
C gcc #9 4.07 33,128 700 15.70
C gcc #8 25.15 19,496 412 25.15
fasta
source secs mem gz cpu secs
C gcc #9 0.78 19,772 1469 0.78
C gcc #5 1.24 19,772 1286 1.24
* Rust #7 0.77 19,804 2533 1.54
Rust #3 1.98 19,804 1235 1.97
C gcc #7 2.76 19,772 1299 2.76
C gcc #6 0.94 19,772 1936 2.78
Rust #2 0.92 19,932 1910 3.09
Rust #9 0.93 19,352 1952 3.13
Rust #5 0.94 19,932 1963 3.14
C gcc #2 0.82 19,772 2276 3.24
Rust #6 3.46 123,652 959 3.45
Rust #4 3.57 123,652 944 3.57
C gcc 3.70 19,772 1213 3.70
Rust 4.24 19,804 1240 4.24
C gcc #8 4.62 19,772 825 4.62
C gcc #4   Make Error  
k-nucleotide
source secs mem gz cpu secs
Rust #7 2.84 133,840 1585 8.91
Rust #6 2.96 159,600 1697 10.67
Rust #3 3.52 137,568 1549 10.78
Rust #5 3.96 137,844 1745 11.95
C gcc 3.84 130,408 1512 12.45
Rust #2 6.28 138,736 1350 16.39
Rust #9 6.44 135,800 1850 17.00
Rust #4 6.74 137,440 1755 18.30
Rust 22.54 157,124 1086 67.38
reverse-complement
source secs mem gz cpu secs
* C gcc #7 0.44 499,992 1899 0.59
C gcc #9 0.48 500,032 1551 0.76
* Rust 0.53 498,816 2762 0.83
C gcc #6 0.96 675,260 828 1.36
C gcc #5 1.53 994,108 654 1.53
C gcc #2 1.06 994,536 757 1.58
Rust #2 0.98 995,200 1332 1.62
Rust #3 0.98 995,200 1105 1.68
* C gcc #4 3.70 500,452 716 3.69
binary-trees
source secs mem gz cpu secs
Rust #5 1.08 198,656 771 3.77
C gcc #2 1.53 169,284 816 4.18
Rust #2 1.22 199,684 729 4.29
C gcc #3 1.96 134,540 842 4.70
Rust #4 1.33 187,948 765 4.80
Rust #3 1.40 188,740 762 5.06
Rust 2.05 132,992 760 7.21
C gcc #8 21.08 285,544 607 21.08
C gcc 21.67 264,244 660 21.67
C gcc #5 8.77 351,332 914 31.93
pidigits
source secs mem gz cpu secs
Rust #4 0.71 19,804 804 0.71
C gcc #2 0.74 19,772 422 0.74
* Rust #3 0.74 19,804 1373 0.74
* Rust 0.74 19,804 1426 0.74
C gcc 0.74 19,772 459 0.74
* Rust #2 0.74 19,804 1312 0.74
regex-redux
source secs mem gz cpu secs
Rust #6 1.18 154,096 994 1.44
Rust 1.33 153,792 811 1.58
Rust #5 1.34 203,224 777 1.58
Rust #2 1.34 153,776 707 1.60
Rust #4 1.35 199,548 771 1.61
Rust #3 1.36 202,908 726 1.61
* Rust #7 0.78 149,888 2464 1.99
C gcc #5 0.81 152,500 1403 2.03
C gcc #2 3.21 103,288 1121 3.21
C gcc #4 0.97 152,264 1237 3.28
C gcc #3 1.72 103,736 1273 3.31
Rust

1.80.1
(3f5fd8dd4
2024-08-06)
LLVM version: 18.1.7

C gcc

gcc (Ubuntu 14.2.0-4ubuntu2) 14.2.0