criterion.rs compatibility layer documentation
A compatibility layer for criterion.rs
Overview
codspeed-criterion-compat
is a Criterion.rs compatibility layer for CodSpeed that allows you to seamlessly integrate existing Criterion benchmarks with CodSpeed performance measurement.
This crate acts as a drop-in replacement for Criterion, maintaining your existing benchmark code while enabling CodSpeed integration.
Installation
This will install the codspeed-criterion-compat
crate and rename it to criterion
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 criterion will still run it as usual.
If you prefer, you can also install codspeed-criterion-compat
as is and change your imports to use this new crate name.
Usage
Let’s start with the example from the Criterion.rs documentation,
creating a benchmark suite for the Fibonacci function (in benches/my_benchmark.rs
):
The last step in creating the Criterion 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
iter_custom
with_filter