|
|
|
|
|
by Dr_Emann
852 days ago
|
|
Hi, I think even the remaining benchmark isn't showing what you're trying to show: https://rust.godbolt.org/z/r9rP6xohb Rust realizes the vector is never used, and so never does any allocation, or recursion, it just turns into a loop to count up to 999_999_999. And some back of the napkin math says there's no way either benchmark is actually allocating anything. Even if malloc took 1 nanosecond (it _doesn't_), 999_999_999 nanoseconds is 0.999999999 seconds. It _is_ somewhat surprising that rust doesn't realize the loop can be completely optimized away, like it does without the unused Vec, but this benchmark still isn't showing what you're trying to show. |
|