divan compatibility layer documentation
A compatibility layer for divan
Overview
codspeed-divan-compat
is a Divan compatibility layer for CodSpeed that allows seamless integration of Divan benchmarks with CodSpeed performance measurement.
This crate acts as a drop-in replacement for Divan, maintaining your existing benchmark code while enabling CodSpeed integration.
Divan is the recommended benchmarking framework for Rust when using CodSpeed due to its modern design and excellent performance characteristics.
Installation
This will install the codspeed-divan-compat
crate and rename it to divan
in your Cargo.toml
.
This way, you can keep your existing imports and the compatibility layer will take care of the rest.
Using the compatibility layer won’t change the behavior of your benchmark suite and divan will still run it as usual.
If you prefer, you can also install codspeed-divan-compat
as is and change your imports to use this new crate name.
Usage
Let’s start with the example from the divan documentation,
creating a benchmark suite for the Fibonacci function (in benches/my_benchmark.rs
):
The last step in creating the divan benchmark is to add the new benchmark target in your Cargo.toml
:
And that’s it! You can now run your benchmark suite with cargo-codspeed
:
Compatibility
Not (yet) supported
divan::bench(crate = xxx)
: due to how the compatibility layer works internally, we do not plan to support this feature.divan::bench_group
: we do not support benchmark grouping yet, if you need it don’t hesitate to create an issue.