-
Notifications
You must be signed in to change notification settings - Fork 0
228 lines (202 loc) · 8.28 KB
/
benchmark.yml
File metadata and controls
228 lines (202 loc) · 8.28 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
name: Benchmark
on:
push:
branches: [main]
paths:
- 'Abies/**'
- 'Abies.Benchmarks/**'
- 'scripts/extract-allocations.py'
- 'scripts/merge-benchmark-results.py'
- 'scripts/compare-benchmarks.py'
- '.github/workflows/benchmark.yml'
pull_request:
branches: [main]
paths:
- 'Abies/**'
- 'Abies.Benchmarks/**'
- 'scripts/extract-allocations.py'
- 'scripts/merge-benchmark-results.py'
- 'scripts/compare-benchmarks.py'
- '.github/workflows/benchmark.yml'
workflow_dispatch:
permissions:
contents: write
deployments: write
pull-requests: write
jobs:
benchmark:
name: Run Benchmarks
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
fetch-depth: 0 # Need full history for branch comparison
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
# ============================================
# BASELINE BENCHMARKS (main branch)
# ============================================
- name: Checkout main branch for baseline
if: github.event_name == 'pull_request'
run: |
git checkout origin/main
echo "Running baseline benchmarks on main branch..."
- name: Restore dependencies (baseline)
if: github.event_name == 'pull_request'
run: dotnet restore Abies.Benchmarks/Abies.Benchmarks.csproj
- name: Build benchmarks (baseline)
if: github.event_name == 'pull_request'
run: dotnet build Abies.Benchmarks/Abies.Benchmarks.csproj -c Release --no-restore
- name: Run DOM Diffing benchmarks (baseline)
if: github.event_name == 'pull_request'
run: >
dotnet run --project Abies.Benchmarks -c Release --no-build --
--filter '*DomDiffingBenchmarks*'
--exporters json
--artifacts ./benchmark-baseline/diffing
- name: Run Rendering benchmarks (baseline)
if: github.event_name == 'pull_request'
run: >
dotnet run --project Abies.Benchmarks -c Release --no-build --
--filter '*RenderingBenchmarks*'
--exporters json
--artifacts ./benchmark-baseline/rendering
- name: Run Event Handler benchmarks (baseline)
if: github.event_name == 'pull_request'
run: >
dotnet run --project Abies.Benchmarks -c Release --no-build --
--filter '*EventHandlerBenchmarks*'
--exporters json
--artifacts ./benchmark-baseline/handlers
- name: Merge baseline benchmark results
if: github.event_name == 'pull_request'
run: python3 scripts/merge-benchmark-results.py ./benchmark-baseline
# ============================================
# PR BENCHMARKS (current PR branch)
# ============================================
- name: Checkout PR branch
if: github.event_name == 'pull_request'
run: |
git checkout ${{ github.head_ref }}
echo "Running PR benchmarks on ${{ github.head_ref }} branch..."
- name: Restore dependencies (PR)
run: dotnet restore Abies.Benchmarks/Abies.Benchmarks.csproj
- name: Build benchmarks (PR)
run: dotnet build Abies.Benchmarks/Abies.Benchmarks.csproj -c Release --no-restore
- name: Run DOM Diffing benchmarks (PR)
run: >
dotnet run --project Abies.Benchmarks -c Release --no-build --
--filter '*DomDiffingBenchmarks*'
--exporters json
--artifacts ./benchmark-results/diffing
- name: Run Rendering benchmarks (PR)
run: >
dotnet run --project Abies.Benchmarks -c Release --no-build --
--filter '*RenderingBenchmarks*'
--exporters json
--artifacts ./benchmark-results/rendering
- name: Run Event Handler benchmarks (PR)
run: >
dotnet run --project Abies.Benchmarks -c Release --no-build --
--filter '*EventHandlerBenchmarks*'
--exporters json
--artifacts ./benchmark-results/handlers
- name: Merge PR benchmark results
run: python3 scripts/merge-benchmark-results.py ./benchmark-results
# ============================================
# SAME-JOB COMPARISON (accurate, no runner variance)
# ============================================
- name: Compare benchmarks (same-job comparison)
if: github.event_name == 'pull_request'
run: |
python3 scripts/compare-benchmarks.py \
./benchmark-baseline/merged \
./benchmark-results/merged \
--throughput-threshold 115 \
--allocation-threshold 120
# ============================================
# HISTORICAL TRACKING (gh-pages, for trends only)
# ============================================
- name: Check if gh-pages exists
id: gh-pages-check
run: |
if git ls-remote --exit-code --heads origin gh-pages > /dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Store throughput to gh-pages (PR - no fail)
uses: benchmark-action/github-action-benchmark@v1
if: github.event_name == 'pull_request' && steps.gh-pages-check.outputs.exists == 'true'
with:
name: Rendering Engine Throughput
tool: benchmarkdotnet
output-file-path: ./benchmark-results/merged/throughput.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: false
save-data-file: false
alert-threshold: '105%'
comment-on-alert: true
fail-on-alert: false # Don't fail here - same-job comparison handles pass/fail
summary-always: true
alert-comment-cc-users: '@MCGPPeters'
- name: Store allocations to gh-pages (PR - no fail)
uses: benchmark-action/github-action-benchmark@v1
if: github.event_name == 'pull_request' && steps.gh-pages-check.outputs.exists == 'true'
with:
name: Rendering Engine Allocations
tool: customSmallerIsBetter
output-file-path: ./benchmark-results/merged/allocations.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: false
save-data-file: false
skip-fetch-gh-pages: true
alert-threshold: '110%'
comment-on-alert: true
fail-on-alert: false # Don't fail here - same-job comparison handles pass/fail
summary-always: true
alert-comment-cc-users: '@MCGPPeters'
- name: Store throughput baseline (main)
uses: benchmark-action/github-action-benchmark@v1
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
with:
name: Rendering Engine Throughput
tool: benchmarkdotnet
output-file-path: ./benchmark-results/merged/throughput.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
save-data-file: true
skip-fetch-gh-pages: ${{ steps.gh-pages-check.outputs.exists != 'true' }}
alert-threshold: '105%'
comment-on-alert: true
fail-on-alert: true
fail-threshold: '110%'
alert-comment-cc-users: '@MCGPPeters'
- name: Store allocation baseline (main)
uses: benchmark-action/github-action-benchmark@v1
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
with:
name: Rendering Engine Allocations
tool: customSmallerIsBetter
output-file-path: ./benchmark-results/merged/allocations.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
save-data-file: true
skip-fetch-gh-pages: false
alert-threshold: '110%'
comment-on-alert: true
fail-on-alert: true
fail-threshold: '120%'
alert-comment-cc-users: '@MCGPPeters'
- name: Upload benchmark artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: benchmark-results
path: |
./benchmark-results/
./benchmark-baseline/
retention-days: 30