Learn how to write benchmarks and measure the performance of your Rust code.
divan
plugin due to its
extensive features, such as running type-generic
benchmarks. Its popularity is growing rapidly within the Rust ecosystem.
If you
are already using criterion
or bencher
, consider their respective plugins,
as they will require minimal adjustments to work with CodSpeed
cargo-codspeed
cargo subcommand: used regardless of
the benchmarking crate.cargo-codspeed
cargo
subcommand:
cargo-codspeed. This tool allows you
to run CodSpeed benchmarks without modifying the behavior of the standard
cargo bench
command.
cargo-codspeed
is the same as with the supported APIs.
So if you already have benchmarks written with one of these, only a minor import change is required.build.rustflags
in .cargo/config.toml
file
when using cargo-codspeed
.However, you can use [target.'cfg(all())']
instead of [build]
as a workaround which does the same and is compatible.cargo-codspeed
CLI tool:
cargo-codspeed
command is
used to help you build and run the benchmark in a CodSpeed environment.
-p
flag to specify
the crate to run the build command on:build
will build and run all the benchmarks in your project.Sometimes you may want to build and run only a subset of your benchmarks. With
the following folder structure:bench1
, you can pass its name as an argument to the build
and
commands:--features
flag to specify the features to enable:cargo codspeed run
will run all the built benchmarks (of the
latest cargo codspeed build ...
command you ran).To run only a subset of the built benchmarks, you can do the following: