Changelog

New updates and improvements released to Codspeed.

Feb 13, 2025

Rust

Divan Support for Rust

Divan Support for Rust

We're excited to announce a new Rust integration with Divan 🛋️, a fast and simple benchmarking framework! 🚀

Divan offers a straightforward API that simplifies the benchmarking process, allowing you to register benchmarks with ease. Unlike Criterion.rs, which can be more complex, or Bencher, which is less feature-rich, Divan provides a balanced approach with its user-friendly interface and powerful capabilities.

Here's an example of how you can use Divan to benchmark a function:

/// benches/fibonacci.rs

fn main() {
    // Run registered benchmarks.
    divan::main();
}

// Register a `fibonacci` function and benchmark it over multiple cases.
#[divan::bench(args = [1, 2, 4, 8, 16, 32])]
fn fibonacci(n: u64) -> u64 {
    if n <= 1 {
        1
    } else {
        fibonacci(n - 2) + fibonacci(n - 1)
    }
}

The divan::bench macro brings a very idiomatic and easy-to-use way to define and customize benchmarks. Bringing this closer to standard test definition while we're waiting on custom test frameworks to be stabilized.

Try it now by checking out our integration guide in the documentation to get started with using Divan in your Rust projects.

We handle performance, so you can focus on shipping.

Talk to our team about deployment, security, and scale; or start building today.