Running Sharded Benchmarks
Running benchmarks can be quite long and slow down your CI process. With CodSpeed, you can run multiple benchmark commands in the same CI workflow. When running heavy benchmark suites, this can divide the total runtime by the number of jobs, dramatically speeding up your CI pipeline.
CodSpeed will then aggregate the corresponding results into a single report.
How to split the execution of benchmark suites?
Sharding allows you to run your benchmarks in several commands, with each command running a subset of your benchmarks.
There are two main ways of sharding your benchmarks:
- splitting them in several files, and running each file or folder independently
- using a sharding tool provided by your benchmarking framework
Check the sharding docs corresponding to your benchmarking framework:
Configure your CI workflow to use sharded benchmarks
Once you've sharded your benchmarks, you can run using several CI jobs within the same workflow, depending on your CI provider:
Multiple languages benchmarks
With benchmarks written in several languages, it can be difficult to get a unified performance overview of your project.
With CodSpeed, you can run benchmarks written in multiple languages. When run in the same CI workflow, CodSpeed will aggregate the results of these benchmarks into a single report.
For example, using pytest
and vitest
:
jobs:
python-benchmarks:
name: "Run Python benchmarks"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install required-version defined in uv.toml
uses: astral-sh/setup-uv@v5
- uses: actions/setup-python@v2
with:
python-version: 3.12.8
- name: Run benchmarks
uses: CodSpeedHQ/action@v3
with:
run: uv run pytest tests/benchmarks/ --codspeed
token: ${{ secrets.CODSPEED_TOKEN }}
nodejs-benchmarks:
name: "Run NodeJS benchmarks"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: "actions/setup-node@v3"
- name: Install dependencies
run: npm install
- name: Run benchmarks
uses: CodSpeedHQ/action@v3
with:
run: npm exec vitest bench
token: ${{ secrets.CODSPEED_TOKEN }}