Getting Started
Installation
Install the CodSpeed CLI using the installation script:codspeed auth login.
Installing a specific version
Installing a specific version
To install a specific version:Replace
v4.8.2 with the version you want to install.You can find all available versions on the
releases page.The CodSpeed CLI officially supports Ubuntu 20.04, 22.04, 24.04 and Debian 11,
12. Other Linux distributions can be used as long as the required tools for
your chosen instruments are manually installed
and available in your
PATH.Run your first command
Let’s run a simple benchmark using the walltime instrument:terminal
Configuration
You can define benchmarks and options in acodspeed.yml configuration file.
Most importantly, items in the benchmarks list describe the commands that are
run when using codspeed run.
Other supported filenames
Other supported filenames
The CodSpeed CLI looks for configuration files with the following names, by order of priority:
codspeed.ymlcodspeed.yaml.codspeed.yml.codspeed.yaml
--config <path>.Benchmark fields
The command to execute. Can include arguments and flags.
A descriptive name for the benchmark. This is used to identify the benchmark
in reports and results.When omitted, the command is used as the benchmark name.
Override global instrument options for this specific benchmark.See the Instruments section for available options for each
instrument and their effects.
Running benchmarks
To run all benchmarks defined in your configuration file, specify the instrument with the-m flag:
terminal
codspeed exec to run a single command:
terminal
Example configuration
codspeed.yml
As displayed in the above example, we provide a schema for the configuration file
here.If your editor supports it, you can use the More information in the
yaml-language-server documentation.
$schema field to enable
autocompletion and validation for the codspeed.yml file.Please note that by default, the VSCode yaml language server does not support
declaring the schema through the $schema field. One of the ways to declare the
schema as is to addcodspeed.yaml
Instruments
CodSpeed supports three instruments for measuring different aspects of your program’s performance.Walltime
The walltime instrument measures real-world execution time. It runs your benchmark multiple times and collects timing data. See the Walltime documentation for more details.How it works
- Warmup phase: The benchmark runs repeatedly until the warmup time is reached. This allows the system to reach a steady state.
- Measurement phase: Based on the average time from warmup, the CodSpeed CLI calculates how many rounds to run within the configured time bounds, then collects timing data for each round.
The walltime instrument requires
sudo privileges to run because it needs to
configure the kernel so that linux
perf can collect all the
necessary events.We plan to fine tune permissions in the future to reduce permissions to the
strict minimum.Profiling for interpreted languages (e.g., Python, JavaScript) is not
currently supported with the walltime instrument.We are currently working on it and it’s coming soon!
Walltime Options
Time spent in warmup runs. Set to
0 to disable warmup.Minimum time spent running measurement rounds.
Maximum time spent running measurement rounds.
Minimum number of measurement rounds.
Maximum number of measurement rounds.
If there is a conflict between time and round constraints, the CodSpeed CLI
prioritizes satisfying the maximum bounds first.
Example
- CLI
- Configuration file
terminal
Memory
The memory instrument tracks heap allocations during benchmark execution. Unlike walltime, the benchmark runs only once while memory usage is recorded. See the Memory documentation for more details. It measures:- Peak memory usage
- Total allocated memory
- Allocation count
- Average allocation size
The memory instrument requires
sudo privileges to run because it uses
eBPF to track memory allocations.We plan to fine tune permissions in the future to reduce permissions to the
strict minimum.Example
terminal
Simulation
The simulation instrument uses CPU simulation to measure performance. The benchmark runs only once and CPU behavior is simulated, providing consistent measurements independent of system load. See the CPU Simulation documentation for more details. This is the same instrument used by CodSpeed integrations when running in CI.Profiling for interpreted languages (e.g., Python, JavaScript) is not
currently supported with the simulation instrument.We are currently working on it and it’s coming soon!
Limitations
Statically linked executables are not currently supported with the simulation instrument. If this is a limitation for your use case, please open a GitHub issue. Additionally, the simulation instrument currently does not follow child processes. Support for this is planned for a future release.Example
terminal
Setting instrument with codspeed use
If you do not want to always explicitly specify the instrument with -m when
running benchmarks, you can set an instrument for your whole shell session by
using
terminal
codspeed run and codspeed exec commands in the current shell session.
You can check the currently selected instrument with
terminal
Running the benchmarks in your CI
To generate performance reports, you need to run the benchmarks in your CI. This allows CodSpeed to automatically run benchmarks and warn you about regressions during development. Here is an example of a GitHub Actions workflow that runs the benchmarks and reports the results to CodSpeed on every push to themain branch and every
pull request:
Contrary to other CI usages, the
run input is intentionally omitted here.This is what defines whether the action will run benchmarks defined in your
configuration file, or a benchmark that makes use of one of the
CodSpeed integrations.Manual tool installation
On Ubuntu and Debian, the CodSpeed CLI automatically installs the tools required by each instrument. On other distributions, you need to install them manually.Walltime
The walltime instrument uses linux perf for profiling, which is enabled by default. Refer to your distribution’s documentation for how to install theperf tool.
If you don’t need profiling data, you can disable it by setting the
CODSPEED_PERF_ENABLED environment variable to false.
Simulation
The simulation instrument requires CodSpeed’s fork of Valgrind. You need to build and install it from source. Prerequisites:git, autoconf, automake, make, and a C compiler.
PATH:
valgrind binary in your PATH must be the CodSpeed version for the
simulation instrument to work correctly.
Memory
The memory instrument requires a Linux kernel with eBPF support. No additional tool installation is needed, the CLI will download and load the necessary tools automatically.Next Steps
Profiling
Learn how to use flame graphs and profiling data to optimize your code
Instruments
Dive into instruments and learn how to measure different aspects of your
program’s performance