Benchmarks
This document provides technical instructions for developers on how to
run, manage, and contribute to the performance benchmarks for
kmeanssa-ng.
Running Benchmarks
Quick benchmarks (fast tests only)
This runs all benchmarks except those marked as @pytest.mark.slow.
All benchmarks (including slow tests)
Compare with a baseline
After making changes, compare performance with the saved baseline:
This will show a comparison table highlighting performance changes.
Saving & Comparing Baselines
Save current performance as a new baseline
Compare against a specific baseline
CI Integration
Benchmarks are not run in CI by default due to performance variability
on shared runners. To enable them, you can add a job like the following
to .gitlab-ci.yml:
benchmark:
stage: test
script:
- pdm run benchmark
allow_failure: true # Don't fail CI on performance variance
Adding New Benchmarks
- Add a new test function to
tests/test_benchmarks.py. - Use the
benchmarkfixture provided bypytest-benchmark. - Mark slow tests with
@pytest.mark.slow. - Ensure the new benchmark is covered by the documentation if it represents a new feature.
For more details, refer to the pytest-benchmark documentation.