Add CodSpeed performance benchmarks
Summary
This PR integrates CodSpeed for continuous performance testing of the OSQP Python solver. It adds a benchmark suite covering the core solver operations and a GitHub Actions workflow that runs these benchmarks on every push to master and on pull requests.
Changes
Benchmark suite (benchmarks/bench_solver.py)
11 benchmarks using pytest-codspeed (compatible with pytest-benchmark API) covering:
- Setup: Solver initialization across small (n=2), medium (n=50), and large (n=200) QP problems
- Solve: Solving QP problems at each size
- Update + solve: Updating linear cost and bounds, then re-solving
- End-to-end: Full setup and solve cycle (small and medium)
- Polishing: Solve with the polishing refinement step enabled
- Warm start: Solve with warm starting from a previous solution
CI workflow (.github/workflows/codspeed.yml)
- Runs on push to
master, pull requests, andworkflow_dispatch(for CodSpeed backtesting) - Uses OIDC authentication (no token needed)
- Builds the C++ extension from source, then runs benchmarks in simulation mode
- Uses
CodSpeedHQ/action@v4
README
- Added CodSpeed badge
Next steps
Once this PR is merged:
- Performance results will be tracked on the CodSpeed dashboard
- Pull requests will receive automated performance reports comparing against the base branch
- Performance regressions will be flagged before they reach
master
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
Congrats! CodSpeed is installed 🎉
🆕 11 new benchmarks were detected.
You will start to see performance impacts in the reports once the benchmarks are run from your default branch.
Detected benchmarks
test_bench_end_to_end_medium: 4.8 mstest_bench_solve_medium: 808.4 µstest_bench_end_to_end_small: 2 mstest_bench_solve_small: 159.4 µstest_bench_setup_large: 18.9 mstest_bench_solve_with_polishing: 1.3 mstest_bench_setup_medium: 3.5 mstest_bench_update_vectors: 888.3 µstest_bench_setup_small: 2 mstest_bench_warm_start_solve: 825.8 µstest_bench_solve_large: 6.4 ms
Congrats! CodSpeed is installed 🎉
🆕 11 new benchmarks were detected.
You will start to see performance impacts in the reports once the benchmarks are run from your default branch.
Detected benchmarks
test_bench_end_to_end_small: 2 mstest_bench_setup_small: 2 mstest_bench_setup_large: 19.1 mstest_bench_solve_large: 6.4 mstest_bench_setup_medium: 3.5 mstest_bench_solve_medium: 808.7 µstest_bench_warm_start_solve: 826.2 µstest_bench_solve_small: 159.9 µstest_bench_solve_with_polishing: 1.3 mstest_bench_update_vectors: 886.9 µstest_bench_end_to_end_medium: 4.8 ms
Note: This PR is experimental, to test out a benchmarking framework I recently learned of. DO NOT MERGE!