Benchmarking results

ProgramC++ (s)1Rust (s)2Ratio (x)3
ackermann0.58490.66961.1448
ary0.04030.04301.0679
ary20.04140.04221.0194
ary30.17070.72174.2281
fibo1.13821.22861.0795
hash0.28290.21040.7437
hash21.16470.82240.7061
heapsort1.59641.60091.0028
lists1.85201.76530.9532
lists10.11860.08620.7265
matrix0.96902.01882.0834
methcall3.03160.42260.1394
moments0.07360.05540.7534
nestedloop0.00170.00150.8347
objinst0.00160.00120.7930
random1.25291.07350.8568
sieve0.94370.90280.9566
strcat0.05340.02480.4640

The outliers are ary3, matrix, methcall and strcat.

I examined the generated code for those to understand the performance differences.


  1. With Clang 20.1.5 on x86_64-pc-linux-gnu, the option -O2, over 30 runs, on an AMD Zen 2 CPU.

  2. With Rustc 1.86.0 (05f9846f8 2025-03-31), the option -O, over 30 runs, on the same machine.

  3. 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.