|
|
|
|
|
by Dr_Emann
853 days ago
|
|
Rust optimizes factorial to be iterative, not using recursion (tail or otherwise) at all, and it turns `factorial(15, 1)` into `1307674368000`: https://rust.godbolt.org/z/bGrWfYKrP. As has been pointed out a few times, you're benchmarking `criterion::black_box` vs `benchmark.keep` (try the newer `std::hint::black_box`, which is built into the compiler and should have lower overhead) And no: in the example with `&String` and `usize`, the stack isn't growing:
https://rust.godbolt.org/z/6zW6WfGE7 |
|
If you could show me a benchmark that supports what you're saying that'd be great, thanks.