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
The benchmarks uses of black_box as a "fence" around outputs to prevent compiler optimization such as optimizing them out (because the compiler would otherwise consider them not used). This is what criterion.rs applies by default.
Context
The benchmarks uses of
black_box
as a "fence" around outputs to prevent compiler optimization such as optimizing them out (because the compiler would otherwise consider them not used). This is whatcriterion.rs
applies by default.For instance in this lookup benchmark:
hashbrown/benches/bench.rs
Line 180 in f2e6212
However, the same must be done for inputs, or they might get optimized along with the code of the benched function. This can make a significant difference in some scenarios. This article explains it well:
https://gendignoux.com/blog/2022/01/31/rust-benchmarks.html#effect-of-stdhintblack_box-on-a-benchmarking-loop
I have tested it on my side, and I do see significant differences (tested on a MacBook pro M1).
Todo
Change:
To:
Same probably applies for other parts of this benchmark.
The text was updated successfully, but these errors were encountered: