Add CodSpeed performance benchmarks and CI integration#2426
Add CodSpeed performance benchmarks and CI integration#2426codspeed-hq[bot] wants to merge 2 commits into
Conversation
Congrats! CodSpeed is installed 🎉
You will start to see performance impacts in the reports once the benchmarks are run from your default branch.
|
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: '3.12' |
There was a problem hiding this comment.
We may want to have the report for different python versions, idk
wdyt @sobolevn?
|
Good question. My recommendation is to keep a single, pinned Python version (the current The reasoning:
A more common pattern is to keep functional correctness tests (your existing If you do specifically want to track per-version performance (e.g. you're tuning for a particular interpreter), it's doable by nesting Summary
Was this response helpful? React with 👍 or 👎 to help us improve CodSpeedBot. |
| pytest-subtests = ">=0.14,<0.16" | ||
| pytest-shard = "^0.1" | ||
| covdefaults = "^2.3" | ||
| pytest-codspeed = "^5.0.3" |
There was a problem hiding this comment.
| pytest-codspeed = "^5.0.3" | |
| pytest-codspeed = "^5.0" |
| return Some(value + 1) | ||
|
|
||
|
|
||
| def test_result_map_chain(benchmark) -> None: |
Both points addressed 👍
All 11 benchmarks pass locally under Summary
Was this response helpful? React with 👍 or 👎 to help us improve CodSpeedBot. |
Summary
This PR sets up continuous performance measurement with CodSpeed for
returns.It adds a benchmark suite for the core containers, wires up a GitHub Actions workflow to run the benchmarks on every push and pull request, and adds the CodSpeed badge to the README.
Changes
benchmarks/test_benchmarks.py— 9pytest-codspeedbenchmarks exercising the hot paths of the most commonly used parts of the library:Resultmap/bind chains, failure recovery via.lash/.value_or, and the@safedecoratorMaybemap chains andNothingshort-circuitingIOmap chainsflowpipelines composed with point-freemap_/bindFold.collectover an iterable ofResultvalues.github/workflows/codspeed.yml— workflow running benchmarks in three instruments:instrumentation) onubuntu-latestmemory) onubuntu-latestwalltime) oncodspeed-macrorunners for stable real-time measurementsid-token: write).pyproject.toml/poetry.lock— addedpytest-codspeedto the dev dependency group and a Ruff per-file-ignore forbenchmarks/*.py(mirroring the existingtests/*.pyrules so benchmark asserts pass linting).README.md— added the CodSpeed badge.Verification
The benchmarks were run locally before opening this PR:
pytest benchmarks/ --codspeed(walltime) — all 9 benchmarks passcodspeed run --mode instrumentation— all 9 benchmarks pass and results upload to thedry-python/returnsprojectNext steps
masterbranch.Future/FutureResult, context containers) as needed.