Benchmarking in stable Rust

Until now, we have seen how to benchmark our code using the nightly release channel. This is because Rust requires the test nightly feature for benchmarks to run. It's where the test crate and the Bencher types can be found. If you still want to be able to use the stable compiler for everything except benchmarks, you can put all your benchmarks in the benches directory. The stable compiler will ignore them for normal builds, but the nightly compiler will be able to run them.

But, if you really want to use the stable compiler to run benchmarks, you can use the bencher crate. You can find it in crates.io, and using it is really similar to using the built-in nightly benchmarks, since this crate is just a stable port ...

Get Rust High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.