Benchmark statistics with Criterion

If we want to know more about benchmark comparison, there is no better library than Criterion. It will generate statistics that you can use to compare benchmarks from multiple commits, and not only that, it will also enable you to show plots if you have gnuplot installed. It requires Rust nightly to run.

Let's see how to use it. First, you will need to add Criterion as a dependency in your Cargo.toml file and create a benchmarks file:

[dev-dependencies]
criterion = "0.1.1"

[[bench]]
name = "example"
harness = false

Then, you will need to create a benchmark. I will be using the Fibonacci function that we saw earlier to demonstrate the behavior. The way to declare the benchmarks is almost exactly the same ...

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.