pub fn black_box<T>(dummy: T) -> T
Expand description

Everything in this module is more or less copied from criterion.rs with some rewrites to make it fit, the license is included in this file’s directory A function that is opaque to the optimizer, used to prevent the compiler from optimizing away computations in a benchmark.

This variant is stable-compatible, but it may cause some performance overhead or fail to prevent code from being eliminated.

use tiny_bench::black_box;
for i in 0..10 {
    assert_eq!(i, black_box(i));
}