You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This section uses the following motivating example to show how you should directly put your tiniest operations (such as a single i + 10 addition) into Criterion and it will benchmark it down to the single instruction level:
Needless to say, f64::sin does not take 300 picoseconds, it's optimized out to compute it once and re-use that computation.
It is sometimes suggested that benchmarks of small (nanosecond-scale) functions should iterate the function to be benchmarked many times internally to reduce the impact of measurement overhead. This is not required with Criterion.rs, and it is not recommended.
I've had a different experience, I would consider this bad general advice, especially when you need varying input to your function with something like iter_batched_ref which then also adds Vec::extend into your measurement, as well as a bunch of memory bandwidth.
The text was updated successfully, but these errors were encountered:
This section uses the following motivating example to show how you should directly put your tiniest operations (such as a single
i + 10
addition) into Criterion and it will benchmark it down to the single instruction level:Allow me to demonstrate this is nonsense, and you're just benchmarking a pre-computed input being
mov
d:Needless to say,
f64::sin
does not take 300 picoseconds, it's optimized out to compute it once and re-use that computation.I've had a different experience, I would consider this bad general advice, especially when you need varying input to your function with something like
iter_batched_ref
which then also addsVec::extend
into your measurement, as well as a bunch of memory bandwidth.The text was updated successfully, but these errors were encountered: