The Computer Language
22.05 Benchmarks Game

Fastest cpu secs C++ g++ versus Rust

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 cpu seconds, less gz source code.

fannkuch-redux
source mem gz cpu
C++ g++ #6 2,000 1528 12.93
C++ g++ #7 992 1150 13.89
Rust #6 1,372 1253 14.15
C++ g++ #5 2,000 980 29.40
Rust #4 1,372 1020 30.06
Rust #3 1,336 1020 30.07
Rust #5 1,368 1016 30.11
C++ g++ #4 2,216 1439 40.52
C++ g++ #3 988 593 40.55
C++ g++ #2 2,224 1440 42.64
C++ g++ 2,164 1059 42.76
Rust #2 1,232 1191 72.42
n-body
source mem gz cpu
C++ g++ #0 964 1927 2.17
Rust #9 1,052 1874 2.89
Rust #7 1,052 1753 3.24
Rust #6 1,028 1790 4.05
C++ g++ #2 1,944 1879 4.06
C++ g++ #7 1,976 1808 4.28
C++ g++ #9 1,260 1530 4.90
Rust #3 1,108 1540 5.49
C++ g++ #6 1,300 1668 5.65
Rust #2 1,032 1805 5.67
Rust 1,044 1480 5.68
C++ g++ #4 1,040 1428 5.68
C++ g++ #3 1,280 1396 5.74
Rust #8 1,104 1767 5.78
C++ g++ 1,260 1659 5.93
C++ g++ #8 1,220 1517 6.08
Rust #5 1,104 2220 6.10
C++ g++ #5 1,944 1749 6.11
Rust #4 1,088 1803 6.25
spectral-norm
source mem gz cpu
Rust #5 2,560 1055 2.84
Rust #6 2,432 1126 2.84
Rust #7 2,436 932 2.84
Rust #4 2,640 817 2.84
C++ g++ #6 1,348 1044 2.85
Rust #2 1,312 1110 2.87
Rust 1,276 1254 2.87
Rust #3 1,248 1053 2.98
C++ g++ #5 2,048 1044 5.26
C++ g++ 1,964 452 5.36
C++ g++ #8 1,348 1278 6.09
mandelbrot
source mem gz cpu
C++ g++ #4 34,720 3542 3.27
C++ g++ 32,336 1791 3.48
C++ g++ #6 31,792 1002 3.88
C++ g++ #0 34,712 2739 4.06
Rust #6 33,872 1332 4.18
Rust #8 32,624 763 5.48
Rust #7 32,732 757 5.50
Rust #3 12,824 1007 5.52
Rust 38,672 868 6.87
Rust #5 33,948 719 10.40
C++ g++ #8 34,448 742 13.19
C++ g++ #5 33,640 590 13.37
C++ g++ #9 34,428 726 13.48
C++ g++ #7 34,392 1017 13.92
C++ g++ #2 34,176 692 17.47
C++ g++ #3 1,976 414 28.53
pidigits
source mem gz cpu
C++ g++ #4 4,220 513 0.71
Rust #4 2,624 799 0.71
C++ g++ #5 4,284 798 0.72
Rust #2 2,924 1306 0.74
Rust 2,928 1420 0.74
Rust #3 2,960 1366 0.83
regex-redux
source mem gz cpu
Rust #6 153,148 986 1.79
Rust #5 202,556 771 1.83
Rust 152,864 804 1.83
Rust #4 202,612 765 1.87
Rust #3 203,408 719 1.89
Rust #2 152,172 701 1.89
Rust #7 147,360 2458 1.99
C++ g++ #6 275,924 2850 2.20
C++ g++ #4 203,888 1315 3.39
C++ g++ 207,788 656 3.57
C++ g++ #2 198,316 700 3.69
C++ g++ #5 214,888 852 4.28
C++ g++ #3 217,248 853 18.28
fasta
source mem gz cpu
Rust #7 2,052 2529 1.52
C++ g++ #8 2,720 2751 1.52
C++ g++ #2 2,004 1127 1.85
C++ g++ 2,000 1057 1.97
Rust #3 1,104 1233 2.03
C++ g++ #3 1,964 1307 2.62
Rust #5 2,580 1961 3.10
Rust #2 2,580 1906 3.18
C++ g++ #4 1,016 1287 3.36
Rust #8 2,596 1946 3.55
Rust #4 123,860 939 3.57
Rust #6 123,848 955 3.58
C++ g++ #5 4,540 2344 3.75
C++ g++ #6 4,564 2324 3.89
Rust 1,100 1237 4.45
C++ g++ #7   Make Error  
k-nucleotide
source mem gz cpu
C++ g++ #2 156,416 1631 5.92
Rust #7 131,236 1578 9.12
Rust #8 137,632 1543 10.39
Rust #6 159,088 1691 10.68
Rust #5 133,912 1739 12.23
C++ g++ #3 165,588 1276 14.14
C++ g++ 756,320 1446 14.54
Rust #2 137,896 1347 16.27
Rust #9 134,732 1841 18.77
Rust #4 136,216 1749 19.31
Rust 152,220 1078 70.04
reverse-complement
source mem gz cpu
C++ g++ #2 499,708 2093 0.64
Rust 499,068 3040 0.76
Rust #2 995,032 1330 1.36
Rust #3 995,032 1097 1.52
C++ g++ #3 500,008 840 2.62
C++ g++ #6 1,513,136 1832 4.00
C++ g++ 979,988 592 6.34
C++ g++ #5 765,148 720 34.88
binary-trees
source mem gz cpu
C++ g++ #7 168,192 890 3.38
Rust #5 198,536 765 3.60
C++ g++ #5 200,020 885 4.10
C++ g++ #9 135,652 809 4.16
Rust #2 200,024 721 4.17
Rust #4 181,444 756 4.40
C++ g++ #3 265,220 945 4.65
C++ g++ #6 265,784 844 4.72
Rust #3 163,904 754 4.87
C++ g++ #8 265,808 820 5.05
Rust 132,604 751 7.70
C++ g++ 1,947,704 754 8.99
C++ g++ #2 265,180 508 22.61
C++ g++ #4   Make Error  
C++ g++

11.2.0-19ubuntu1

Rust

rustc 1.60.0
(7737e0b5c
2022-04-04)
LLVM version: 14.0.0