Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

divan

> 数据库
Open source

Fast and simple benchmarking for Rust projects

1.4K stars0 likes1 views
WebsiteGitHub

About

Fast and simple benchmarking for Rust projects

Sponsor

If you or your company find Divan valuable, consider sponsoring on GitHub or donating via PayPal. Sponsorships help me progress on what's possible with benchmarking in Rust.

Guide

A guide is being worked on. In the meantime, see:

  • Announcement post
  • "Proving Performance" FOSDEM talk

Getting Started

Divan 0.1.21 requires Rust 1.80.0 or later.

  1. Add the following to your project's Cargo.toml:

    toml
    [dev-dependencies]
    divan = "0.1.21"
    
    [[bench]]
    name = "example"
    harness = false
  2. Create a benchmarks file at benches/example.rs[^1] with your benchmarking code:

    rust
    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)
        }
    }
  3. Run your benchmarks with cargo bench:

…

See #[divan::bench] for info on benchmark function registration.

Checking benchmarks in CI

If you want to run each benchmarked function only once (to check that they don't panic without measuring their performance), you can run the benchmark runner crate with the --test parameter. You can do so by running either

bash
cargo bench -- --test

or

bash
cargo test --benches

Examples

Practical example benchmarks can be found in the examples/benches directory. These can be benchmarked locally by running:

bash
git clone https://github.com/nvzqz/divan.git
cd divan

cargo bench -q -p examples --all-features

More thorough usage examples can be found in the #[divan::bench] documentation.

License

Like the Rust project, this library may be used under either the MIT License or Apache License (Version 2.0).

[^1]: Within your crate directory, i.e. $CARGO_MANIFEST_DIR

Issues· 51 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustbenchmarkfastperformancerust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库