-
Notifications
You must be signed in to change notification settings - Fork 830
176 lines (154 loc) · 6.11 KB
/
Copy pathpr-benchmarks.yml
File metadata and controls
176 lines (154 loc) · 6.11 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
---
name: PR Benchmarks
on:
pull_request:
types:
- labeled
permissions: {}
concurrency:
group: pr-benchmarks-${{ github.event.pull_request.number }}
defaults:
run:
shell: bash
jobs:
benchmark:
if: github.event.label.name == 'benchmark'
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- topic: counter
pattern: CounterBenchmark
- topic: histogram
pattern: HistogramBenchmark
- topic: exposition
pattern: HistogramTextFormatBenchmark|TextFormatUtilBenchmark
permissions:
contents: read # checkout only
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_NUMBER: ${{ github.event.pull_request.number }}
JMH_PATTERN: ${{ matrix.pattern }}
steps:
- name: Checkout PR base
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: ${{ github.repository }}
ref: ${{ github.event.pull_request.base.sha }}
persist-credentials: false
fetch-depth: 0
- name: Setup mise
uses: jdx/mise-action@dad1bfd3df957f44999b559dd69dc1671cb4e9ea # v4.2.1
with:
version: v2026.7.5
sha256: 5f7ab76afdf0780d12edeaa67e908094e9ccf7924cfe203e415c1cfb87bbf778
- name: Cache local Maven repository
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.m2/repository
key: ${{ runner.os }}-pr-bench-maven-${{ matrix.topic }}-${{ env.HEAD_SHA }}
restore-keys: |
${{ runner.os }}-pr-bench-maven-${{ matrix.topic }}-
${{ runner.os }}-pr-bench-maven-
${{ runner.os }}-maven-
- name: Capture runner info
run: |
python3 ./.mise/tasks/generate_benchmark_summary.py \
--write-system-info /tmp/runner-info.json
- name: Run base ${{ matrix.topic }} benchmarks
run: mise run benchmark:ci-json
env:
JMH_ARGS: -f 3 -wi 3 -i 5 ${{ env.JMH_PATTERN }}
- name: Save base ${{ matrix.topic }} results
run: mv benchmark-results.json /tmp/base-results.json
- name: Checkout PR head
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
fetch-depth: 0
- name: Run head ${{ matrix.topic }} benchmarks
run: mise run benchmark:ci-json
env:
JMH_ARGS: -f 3 -wi 3 -i 5 ${{ env.JMH_PATTERN }}
- name: Save head ${{ matrix.topic }} results
run: mv benchmark-results.json /tmp/head-results.json
- name: Upload ${{ matrix.topic }} benchmark results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: pr-benchmark-topic-${{ matrix.topic }}-${{ env.PR_NUMBER }}-${{ env.HEAD_SHA }}
path: |
/tmp/base-results.json
/tmp/head-results.json
/tmp/runner-info.json
retention-days: 5
summarize:
if: github.event.label.name == 'benchmark'
runs-on: ubuntu-24.04
needs: benchmark
permissions:
contents: read # checkout only
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_NUMBER: ${{ github.event.pull_request.number }}
steps:
- name: Checkout PR head
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
fetch-depth: 0
- name: Download topic benchmark results
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: pr-benchmark-topic-*-${{ env.PR_NUMBER }}-${{ env.HEAD_SHA }}
path: /tmp/topic-benchmark-results
- name: Merge topic benchmark results
run: |
python3 - <<'PY'
import json
from pathlib import Path
root = Path('/tmp/topic-benchmark-results')
for name in ('base', 'head'):
files = sorted(root.glob(f'*/{name}-results.json'))
if not files:
raise SystemExit(f'No {name} benchmark result files found')
merged = []
for file in files:
with open(file, 'r') as f:
merged.extend(json.load(f))
with open(f'/tmp/{name}-benchmark-results.json', 'w') as f:
json.dump(merged, f)
f.write('\n')
PY
- name: Generate benchmark summary
run: |
python3 ./.mise/tasks/generate_benchmark_summary.py \
--input /tmp/head-benchmark-results.json \
--baseline /tmp/base-benchmark-results.json \
--output-dir benchmark-results \
--commit-sha "${{ github.event.pull_request.head.sha }}" \
--baseline-sha "${{ github.event.pull_request.base.sha }}" \
--comparison-note \
"Base and head are compared on the same runner within each topic."
env:
GITHUB_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}
GITHUB_BASE_REPOSITORY: ${{ github.repository }}
- name: Prepare PR comment summary
run: |
cp benchmark-results/README.md pr-benchmark-comment.md
- name: Upload PR benchmark results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: pr-benchmark-results-pr-${{ env.PR_NUMBER }}-${{ env.HEAD_SHA }}
path: benchmark-results
retention-days: 5
- name: Upload PR benchmark comment
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: pr-benchmark-comment-pr-${{ env.PR_NUMBER }}-${{ env.HEAD_SHA }}
path: pr-benchmark-comment.md
retention-days: 5