Skip to content

Commit cdc987b

Browse files
APN-PuckyCopilot
andauthored
ci: Add benchmark ci (#328)
* add benchmark ci * install twice do to switch branch * explicit bench mark pytest install * Drop benchmark ci for now * CI in separate commit * run on every pull request * Update .github/workflows/benchmark.yml Co-authored-by: Copilot <[email protected]> * clean * clean a bit * markdown * Clean output * fail on 10% drop and compare * safe benchmark cross checkout * benchmark compare with int * What happens on new function/rename? * Add a quick warmup run * 5% --------- Co-authored-by: Copilot <[email protected]>
1 parent dc718ad commit cdc987b

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

.github/workflows/benchmark.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Benchmark Comparison
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
benchmark:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout PR branch
12+
uses: actions/checkout@v5
13+
with:
14+
fetch-depth: 0 # important to fetch full history for git compare
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v6
18+
with:
19+
python-version: "3.13"
20+
21+
22+
- uses: astral-sh/setup-uv@v7
23+
24+
- name: Install base
25+
run: |
26+
git checkout ${{ github.event.pull_request.base.sha }}
27+
uv pip install --system '.[test]'
28+
29+
# Run benchmarks on base
30+
- name: Run benchmarks on base
31+
run: |
32+
pytest benchmarks --benchmark-only --benchmark-warmup='on' --benchmark-warmup-iterations=1 --benchmark-min-rounds=10 --benchmark-save=base --no-cov --disable-warnings
33+
34+
- name: Install PR
35+
run: |
36+
git checkout -
37+
uv pip install --system '.[test]'
38+
39+
# Run benchmarks on MR
40+
- name: Run benchmarks on MR
41+
run: |
42+
pytest benchmarks --benchmark-only --benchmark-warmup='on' --benchmark-warmup-iterations=1 --benchmark-min-rounds=10 --benchmark-save=mr --benchmark-compare=0001_base --benchmark-compare-fail=min:5% --no-cov --disable-warnings
43+
44+
# Compare results
45+
- name: Run benchmarks on PR and compare
46+
id: compare
47+
run: |
48+
set +e
49+
result=$(pytest-benchmark compare)
50+
echo "$result"
51+
echo "result<<EOF" >> $GITHUB_OUTPUT
52+
echo "$result" >> $GITHUB_OUTPUT
53+
echo "EOF" >> $GITHUB_OUTPUT
54+
55+
# Post a comment to the PR with results
56+
- name: Comment on PR
57+
uses: marocchino/sticky-pull-request-comment@v2
58+
with:
59+
header: benchmark
60+
message: |
61+
## 🏎️ Benchmark Comparison
62+
```
63+
${{ steps.compare.outputs.result }}
64+
```

benchmarks/test_awkward_bench.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
]
2727

2828

29-
def test_fromfile_and_to_awkward_benchmark_collective(benchmark):
29+
def test_fromfile_and_to_awkward(benchmark):
3030
"""Benchmark LHEFile.fromfile and to_awkward conversion across all test files."""
3131

3232
def fromfile_and_to_awkward_all_files(filepaths):

0 commit comments

Comments
 (0)