Skip to main content
CI StatusCrates.io Version

Overview

cargo-codspeed is a Cargo subcommand for running performance benchmarks with CodSpeed. It provides an easy way to build and run benchmarks for Rust projects with CodSpeed integration.

Installation

With cargo

cargo install cargo-codspeed --locked
cargo-binstall enables you to install binaries directly without having to build from the source(with cargo install) every time. If you don’t have installed yet, you can install it with:
cargo install cargo-binstall
You can then install cargo-codspeed with:
cargo binstall cargo-codspeed

Usage

Building Benchmarks

Build your benchmarks for CodSpeed:
cargo codspeed build

Running Benchmarks

Run the previously built benchmarks:
cargo codspeed run

The --measurement-mode flag

When building benchmarks, you can specify the measurement mode using the --measurement-mode / -m flag. This determines which CodSpeed instrument can be used to run your benchmarks.
# First build the benchmarks:
cargo codspeed build -m simulation

# Then run them:
cargo codspeed run -m simulation
The --measurement-mode flag can take the following values:
  • simulation: Runs benchmarks once on a simulated CPU for consistent measurements.
  • walltime: Measures wall-clock time for real-world scenarios.
  • memory: Benchmarks are run once using memory profiling to track heap allocations and memory usage.
If you omit the --measurement-mode flag, the default behavior is to build for simulation mode.