Benchmarking results
Program | C++ (s)1 | Rust (s)2 | Ratio (x)3 |
---|---|---|---|
ackermann | 0.5849 | 0.6696 | 1.1448 |
ary | 0.0403 | 0.0430 | 1.0679 |
ary2 | 0.0414 | 0.0422 | 1.0194 |
ary3 | 0.1707 | 0.7217 | 4.2281 |
fibo | 1.1382 | 1.2286 | 1.0795 |
hash | 0.2829 | 0.2104 | 0.7437 |
hash2 | 1.1647 | 0.8224 | 0.7061 |
heapsort | 1.5964 | 1.6009 | 1.0028 |
lists | 1.8520 | 1.7653 | 0.9532 |
lists1 | 0.1186 | 0.0862 | 0.7265 |
matrix | 0.9690 | 2.0188 | 2.0834 |
methcall | 3.0316 | 0.4226 | 0.1394 |
moments | 0.0736 | 0.0554 | 0.7534 |
nestedloop | 0.0017 | 0.0015 | 0.8347 |
objinst | 0.0016 | 0.0012 | 0.7930 |
random | 1.2529 | 1.0735 | 0.8568 |
sieve | 0.9437 | 0.9028 | 0.9566 |
strcat | 0.0534 | 0.0248 | 0.4640 |
The outliers are ary3
, matrix
, methcall
and strcat
.
I examined the generated code for those to understand the performance differences.
-
With Clang 20.1.5 on x86_64-pc-linux-gnu, the option
-O2
, over 30 runs, on an AMD Zen 2 CPU. ↩ -
With Rustc 1.86.0 (05f9846f8 2025-03-31), the option
-O
, over 30 runs, on the same machine. ↩ -
Ratios > 1.0 indicates the Rust version was slower than the C++ version. Ratios < 1.0 indicates the Rust version was faster than the C++ version. ↩