-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (72 loc) · 2.55 KB
/
Copy pathbenchmark.yml
File metadata and controls
87 lines (72 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Benchmark PR
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-bench-${{ hashFiles('**/Cargo.lock') }}
- name: Benchmark main branch
run: |
git fetch origin ${{ github.base_ref }}
git checkout origin/${{ github.base_ref }}
cargo bench --bench flatten --color never -- --save-baseline main
- name: Benchmark PR branch
run: |
git checkout ${{ github.event.pull_request.head.sha }}
cargo bench --bench flatten --color never -- --baseline main > bench_output.txt 2>&1
- name: Extract comparison summary
run: |
grep -E "(^flatten_|^\s+(time:|thrpt:|change:)|Performance has)" bench_output.txt > bench_summary.txt || echo "No comparison data" > bench_summary.txt
cat bench_summary.txt
- name: Comment PR
uses: actions/github-script@v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const output = fs.readFileSync('bench_summary.txt', 'utf8');
const body = `## Benchmark Results
\`\`\`
${output}
\`\`\`
---
Benchmarked on commit \`${{ github.event.pull_request.head.sha }}\``;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(c =>
c.user.login === 'github-actions[bot]' &&
c.body.includes('Benchmark Results')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}