The Computer Language
24.11 Benchmarks Game

Rust versus C++ g++ 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++ g++ #6 3.31 19,760 1535 13.11
* C++ g++ #7 14.03 19,760 1156 14.03
* 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++ g++ #5 7.85 19,760 987 30.68
C++ g++ #4 8.92 19,760 1445 35.00
C++ g++ #2 9.13 19,760 1446 35.73
Rust #2 9.15 19,684 1198 35.91
C++ g++ #3 37.88 19,760 600 37.87
C++ g++ 10.49 19,760 1065 41.21
n-body
source secs mem gz cpu secs
* C++ g++ #0 2.15 19,760 1933 2.15
* Rust #9 2.19 19,624 1881 2.19
* 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
* C++ g++ #7 4.11 19,760 1815 4.11
* Rust #6 4.36 19,624 1796 4.35
* Rust #5 5.01 19,624 2224 5.01
Rust #4 5.11 19,624 1810 5.11
C++ g++ #9 5.14 19,760 1536 5.14
C++ g++ #3 5.32 19,760 1402 5.32
* C++ g++ #4 5.45 19,760 1434 5.45
Rust 5.52 19,624 1483 5.52
* C++ g++ #2 6.02 19,352 1524 6.01
C++ g++ #5 6.32 19,760 1544 6.32
C++ g++ 6.61 19,760 1666 6.61
C++ g++ #6 6.93 19,760 1674 6.93
spectral-norm
source secs mem gz cpu secs
* 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
* C++ g++ #6 0.73 19,760 1050 2.86
* Rust #3 0.74 19,632 1060 2.86
* C++ g++ #5 1.33 19,760 1050 5.28
C++ g++ 5.33 19,760 459 5.33
C++ g++ #7 1.52 19,512 1284 6.04
* Rust #7   Make Error  
mandelbrot
source secs mem gz cpu secs
* C++ g++ #4 0.89 35,344 3554 3.45
* C++ g++ 0.89 34,952 1797 3.47
* Rust #4 0.95 33,392 1301 3.77
* C++ g++ #6 0.98 35,080 1014 3.87
* 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
Rust 2.00 39,404 874 7.88
C++ g++ #0 2.35 35,476 2752 9.30
* C++ g++ #7 4.86 35,176 749 13.28
C++ g++ #5 13.44 34,636 596 13.43
C++ g++ #9 3.52 35,120 732 13.55
C++ g++ #2 16.95 34,636 700 16.94
C++ g++ #3 27.37 19,760 421 27.36
fasta
source secs mem gz cpu secs
* Rust #7 0.77 19,624 2533 1.54
C++ g++ #9 0.78 19,352 2758 1.54
C++ g++ #2 1.84 19,760 1129 1.84
C++ g++ 1.92 19,760 1064 1.92
Rust #3 1.98 19,624 1235 1.98
C++ g++ #3 2.63 19,760 1311 2.63
C++ g++ #7 0.87 19,760 2711 3.05
Rust #9 0.94 19,624 1952 3.22
C++ g++ #4 3.32 19,760 1291 3.32
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
Rust #4 3.47 123,848 944 3.46
C++ g++ #5 1.06 19,760 2345 3.66
C++ g++ #6 1.07 19,760 2326 4.01
Rust 4.25 19,624 1240 4.25
k-nucleotide
source secs mem gz cpu secs
C++ g++ #2 2.01 156,592 1634 5.98
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++ g++ #3 4.19 165,580 1280 13.94
C++ g++ 6.96 757,156 1452 14.75
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++ g++ #2 0.74 499,916 2099 0.74
* Rust 0.53 498,952 2762 0.84
Rust #2 0.95 995,220 1332 1.58
Rust #3 0.97 995,156 1105 1.69
C++ g++ #6 3.30 1,517,824 1827 4.38
C++ g++ 6.52 980,156 599 6.51
C++ g++ #5 37.59 771,632 704 37.58
C++ g++ #3   Bad Output  
binary-trees
source secs mem gz cpu secs
C++ g++ #7 0.97 201,512 896 3.40
Rust #5 1.09 198,720 771 3.84
C++ g++ #5 1.16 200,724 891 4.10
Rust #2 1.19 199,796 729 4.21
C++ g++ #9 1.74 136,120 815 4.63
C++ g++ #3 1.91 265,636 951 4.74
C++ g++ #6 1.91 266,120 851 4.77
Rust #3 1.39 189,928 762 5.00
Rust #4 1.39 199,084 765 5.01
C++ g++ #4 2.22 266,136 826 5.20
Rust 2.04 132,952 760 7.26
C++ g++ 2.65 2,153,044 760 9.23
C++ g++ #2 22.83 265,840 514 22.82
pidigits
source secs mem gz cpu secs
Rust #4 0.71 19,624 804 0.71
C++ g++ #4 0.71 19,760 521 0.71
* C++ g++ #5 0.73 19,760 804 0.73
* Rust #3 0.74 19,624 1373 0.74
* Rust #2 0.74 19,624 1312 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++ g++ #6 1.15 276,336 2856 2.24
C++ g++ #3 12.38 215,640 859 17.95
C++ g++   Make Error  
C++ g++ #2   Make Error  
C++ g++ #5   Make Error  
C++ g++ #4   Make Error  
Rust

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

C++ g++

g++ (Ubuntu 14.2.0-4ubuntu2) 14.2.0