-
Notifications
You must be signed in to change notification settings - Fork 117
95 lines (82 loc) · 2.92 KB
/
Copy pathbenchmark.yml
File metadata and controls
95 lines (82 loc) · 2.92 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
88
89
90
91
92
93
94
95
name: Benchmarks
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
benchmark:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Install dependencies
run: npm ci --legacy-peer-deps
- name: Run benchmarks
id: bench
run: npm run bench -- --reporter=verbose 2>&1 | tee bench-results.txt
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results-node${{ matrix.node-version }}
path: bench-results.txt
- name: Check for regressions
run: |
# Flag if any benchmark shows >10% slower than baseline
# Baseline thresholds (ops/sec):
# result construction: > 1,000,000 ops/sec
# validateTransaction: > 100,000 ops/sec
# formatAddress: > 1,000,000 ops/sec
#
# Currently: report results only. Regression gating can be enabled
# once stable baselines are committed to the repo.
echo "Benchmark results for Node.js ${{ matrix.node-version }}:"
cat bench-results.txt
- name: Post benchmark results as PR comment
if: github.event_name == 'pull_request' && matrix.node-version == '20.x'
continue-on-error: true
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const results = fs.readFileSync('bench-results.txt', 'utf8');
const body = [
'## Benchmark Results (Node 20)',
'',
'```',
results.slice(0, 5000),
'```',
'',
'_Benchmarks run on Node.js 20.x. Acceptable regression threshold: 10% slower than baseline._',
].join('\n');
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(c =>
c.user.login === 'github-actions[bot]' &&
c.body.startsWith('## Benchmark Results')
);
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}