Skip to content

Commit

Permalink
Add pytest-benchmark to dev dependencies and run benchmark checks on …
Browse files Browse the repository at this point in the history
…PRs (#177)

* Add pytest-benchmark to dev dependencies

* Run benchmark for PRs

* Don't fail on benchmark alert
  • Loading branch information
domna authored Jun 19, 2024
1 parent 2fa65c8 commit 19b18ca
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Benchmark
on:
push:
branches:
- master
branches: [master]
pull_request:
branches: [master]

permissions:
contents: write
Expand All @@ -22,15 +23,15 @@ jobs:
- name: Install deps
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install --system -r requirements/fitting-requirements.txt
uv pip install --system pytest pytest-benchmark pytest-coverage
uv pip install --system -r requirements/dev-requirements.txt
- name: Install module
run: |
uv pip install --system .
- name: Run benchmark
run: |
pytest tests/benchmark*.py --benchmark-json output.json
- name: Store benchmark result
if: github.ref == 'refs/heads/master'
uses: benchmark-action/github-action-benchmark@v1
with:
name: Python Benchmark with pytest-benchmark
Expand All @@ -41,5 +42,18 @@ jobs:
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: "200%"
comment-on-alert: false
fail-on-alert: false
- name: Check benchmark threshold
if: github.ref != 'refs/heads/master'
uses: benchmark-action/github-action-benchmark@v1
with:
name: Python Benchmark with pytest-benchmark
tool: "pytest"
output-file-path: output.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: false
# Show alert with commit comment on detecting possible performance regression
alert-threshold: "200%"
comment-on-alert: true
fail-on-alert: true
fail-on-alert: false
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ fitting = [
]
dev = [
"pytest",
"pytest-benchmark",
"pytest-cov",
"nbmake",
"ruff==0.4.8",
Expand Down
9 changes: 9 additions & 0 deletions requirements/dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,10 @@ pure-eval==0.2.2 \
# via
# -r requirements/fitting-requirements.txt
# stack-data
py-cpuinfo==9.0.0 \
--hash=sha256:3cdbbf3fac90dc6f118bfd64384f309edeadd902d7c8fb17f02ffa1fc3f49690 \
--hash=sha256:859625bc251f64e21f077d099d4162689c762b5d6a4c3c97553d56241c9674d5
# via pytest-benchmark
pygments==2.18.0 \
--hash=sha256:786ff802f32e91311bff3889f6e9a86e81505fe99f2735bb6d60ae0c5004f199 \
--hash=sha256:b8e6aca0523f3ab76fee51799c488e38782ac06eafcf95e7ba832985c8e7b13a
Expand All @@ -803,7 +807,12 @@ pytest==8.2.2 \
# via
# pyelli (pyproject.toml)
# nbmake
# pytest-benchmark
# pytest-cov
pytest-benchmark==4.0.0 \
--hash=sha256:fb0785b83efe599a6a956361c0691ae1dbb5318018561af10f3e915caa0048d1 \
--hash=sha256:fdb7db64e31c8b277dff9850d2a2556d8b60bcb0ea6524e36e28ffd7c87f71d6
# via pyelli (pyproject.toml)
pytest-cov==5.0.0 \
--hash=sha256:4f0764a1219df53214206bf1feea4633c3b558a2925c8b59f144f682861ce652 \
--hash=sha256:5837b58e9f6ebd335b0f8060eecce69b662415b16dc503883a02f45dfeb14857
Expand Down

0 comments on commit 19b18ca

Please sign in to comment.