Skip to content

Commit c453b96

Browse files
authored
run benchmarks in CI and upload results (#549)
1 parent 9668055 commit c453b96

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/workflows/benchmark.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Benchmark
2+
3+
on:
4+
pull_request: {}
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
benchmark:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout PR
14+
uses: actions/[email protected]
15+
with:
16+
persist-credentials: false
17+
fetch-depth: 0
18+
19+
- name: Install Rust toolchain
20+
uses: dtolnay/rust-toolchain@888c2e1ea69ab0d4330cbf0af1ecc7b68f368cc1
21+
with:
22+
toolchain: stable
23+
24+
- name: Install critcmp
25+
run: cargo install critcmp
26+
27+
- name: Run benchmarks on main
28+
run: |
29+
git checkout origin/main
30+
cargo bench --bench basic -- --save-baseline main
31+
32+
- name: Run benchmarks on PR
33+
run: |
34+
git checkout ${{ github.event.pull_request.head.sha }}
35+
cargo bench --bench basic -- --save-baseline pr
36+
37+
- name: Generate benchmark report
38+
run: |
39+
echo "# 📊 Benchmark Results" >> $GITHUB_STEP_SUMMARY
40+
echo "" >> $GITHUB_STEP_SUMMARY
41+
echo "Comparison between \`main\` and this PR:" >> $GITHUB_STEP_SUMMARY
42+
echo "" >> $GITHUB_STEP_SUMMARY
43+
echo "## Benchmark Comparison" >> $GITHUB_STEP_SUMMARY
44+
echo "" >> $GITHUB_STEP_SUMMARY
45+
echo '```' >> $GITHUB_STEP_SUMMARY
46+
if critcmp main pr 2>&1 | tee comparison_output.txt; then
47+
cat comparison_output.txt >> $GITHUB_STEP_SUMMARY
48+
else
49+
echo "Error: Could not compare benchmarks. This might be due to:" >> $GITHUB_STEP_SUMMARY
50+
echo "- Benchmark names changed between main and PR" >> $GITHUB_STEP_SUMMARY
51+
echo "- Insufficient data for comparison" >> $GITHUB_STEP_SUMMARY
52+
echo "- Build or test failures" >> $GITHUB_STEP_SUMMARY
53+
fi
54+
echo '```' >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)