What tools and workflows do you use for benchmarking?

I’m interested in hearing what what benchmarking workflows work for you. Are there any particular crates that are a must? Do you use nightly for it? Do you separate the bench tests into their own project?

I’ve heard good things about https://bheisler.github.io/criterion.rs/book/index.html


For simpler cases, the built-in test crate does the job:

extern crate test;
use test::Bencher;

fn benchmark(b: &mut Bencher) {
    b.iter(|| {
        // benchmarking code here

Like tests, you can put it into a separate directory benches. Execute it with cargo bench on nightly.

I generally try to keep the benches relevant so I just try to custom create or use a specific bench for my projects. I rarely use the same one every where, but yeah some components are common.

In Rust I haven’t written on of my own yet just reused good ones I found from relevant projects or places.

Using the built-in test crate is a good foundation. :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.