-
Notifications
You must be signed in to change notification settings - Fork 4
303 lines (265 loc) · 11 KB
/
benchmark.yml
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
name: Benchmark
on:
pull_request_target:
branches: [ main ]
types: [ opened ]
issue_comment:
types: [ created ]
jobs:
check-command:
runs-on: windows-2019
permissions:
pull-requests: write
outputs:
benchmark: ${{ steps.check.outputs.triggered }}
ref: ${{ env.CUSTOM_REF }}
repo: ${{ env.CUSTOM_REPO }}
steps:
- name: Print Event Name
run: echo "${{ github.EVENT_NAME }}"
- name: Check Benchmark Trigger
if: ${{ github.EVENT_NAME != 'pull_request_target' }}
uses: khan/pull-request-comment-trigger@master
id: check
with:
trigger: '/benchmark'
reaction: eyes
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- name: Find Branch
uses: actions/github-script@v3
id: find-branch
with:
script: |
const request = {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
}
core.info(`Getting PR #${request.pull_number} from ${request.owner}/${request.repo}`)
try {
const result = await github.pulls.get(request)
return result.data
} catch (err) {
core.setFailed(`Request failed with error ${err}`)
}
- name: Set Repository and Ref
run: |
$repository = '${{ fromJSON(steps.find-branch.outputs.result).head.repo.full_name }}'
$ref = '${{ fromJSON(steps.find-branch.outputs.result).head.ref }}'
echo "CUSTOM_REPO=$($repository)" >> $env:GITHUB_ENV
echo "CUSTOM_REF=$($ref)" >> $env:GITHUB_ENV
benchmark-build:
if: ${{ needs.check-command.outputs.benchmark == 'true' || github.EVENT_NAME == 'pull_request_target' }}
needs: check-command
runs-on: windows-2019
outputs:
repo: ${{ needs.check-command.outputs.repo }}
ref: ${{ needs.check-command.outputs.ref }}
package_version: ${{ env.PACKAGE_VERSION }}
steps:
- uses: actions/checkout@v2
with:
repository: ${{ needs.check-command.outputs.repo }}
ref: ${{ needs.check-command.outputs.ref }}
submodules: 'true'
- name: Ensure .NET 5 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.302
- name: Ensure .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.101
- name: Install Build Dependencies
run: |
choco install meson
choco install ninja
choco install nasm
echo "C:\Program Files\NASM" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\Program Files\Meson" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Set NuGet Version
run: echo "PACKAGE_VERSION=1.0.0-benchmark.${{ GITHUB.RUN_NUMBER }}" >> $env:GITHUB_ENV
- name: Build
run: dotnet build -c Release
working-directory: ./src/FileOnQ.Imaging.Heif
- name: Pack
run: dotnet pack -c Release -o ../../ /p:ContinuousIntegrationBuild=true /p:Version=${{ env.PACKAGE_VERSION }} /p:PackageVersion=${{ env.PACKAGE_VERSION }}
working-directory: ./src/FileOnQ.Imaging.Heif
- name: Upload NuGet Package
uses: actions/upload-artifact@v2
with:
name: Benchmark-Packages
path: |
*.nupkg
*.snupkg
benchmark-run:
if: ${{ needs.check-command.outputs.benchmark == 'true' || github.EVENT_NAME == 'pull_request_target' }}
needs: benchmark-build
runs-on: ${{ matrix.os }}
outputs:
repo: ${{ needs.benchmark-build.outputs.repo }}
ref: ${{ needs.benchmark-build.outputs.ref }}
strategy:
matrix:
include:
- os: windows-2019
framework: 'net48'
benchmark: 'thumbnail'
- os: windows-2019
framework: 'net5.0'
benchmark: 'thumbnail'
- os: windows-2019
framework: 'net6.0'
benchmark: 'thumbnail'
- os: windows-2019
framework: 'net48'
benchmark: 'primary'
- os: windows-2019
framework: 'net5.0'
benchmark: 'primary'
- os: windows-2019
framework: 'net6.0'
benchmark: 'primary'
steps:
- uses: actions/checkout@v2
with:
repository: ${{ needs.benchmark-build.outputs.repo }}
ref: ${{ needs.benchmark-build.outputs.ref }}
submodules: 'true'
- name: Ensure .NET 5 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.302
- name: Ensure .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.101
- name: Download Artifacts
uses: actions/download-artifact@v2
- name: Copy Nupkg
shell: powershell
run: Copy-Item Benchmark-Packages\* -Destination .
- name: Update NuGet
run: dotnet add package FileOnQ.Imaging.Heif --version ${{ needs.benchmark-build.outputs.package_version }}
working-directory: ./benchmarks/tools
- name: Benchmark
run: dotnet run -c Release -f ${{ matrix.framework }} -b ${{ matrix.benchmark }}
working-directory: ./benchmarks/tools
- name: Upload Results
uses: actions/upload-artifact@v2
with:
name: Benchmark-${{ matrix.benchmark }}.${{ matrix.framework }}
path: ./benchmarks/tools/BenchmarkDotNet.Artifacts/results
benchmark-compare:
if: ${{ needs.check-command.outputs.benchmark == 'true' || github.EVENT_NAME == 'pull_request_target' }}
needs: benchmark-run
runs-on: windows-2019
strategy:
matrix:
include:
- framework: 'net48'
name: '.NET Framework 4.8'
- framework: 'net5.0'
name: '.NET 5'
- framework: 'net6.0'
name: '.NET 6'
steps:
- name: Clone fileonq/imaging.heif
uses: actions/checkout@v2
with:
repository: ${{ needs.benchmark-run.outputs.repo }}
ref: ${{ needs.benchmark-run.outputs.ref }}
path: fileonq.imaging.heif
- name: Clone dotnet/performance
uses: actions/checkout@v2
with:
repository: dotnet/performance
path: dotnet.performance
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Ensure .NET 5 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.302
- name: Build Compare Tool
run: dotnet build
working-directory: ./dotnet.performance/src/tools/ResultsComparer
- name: Compare - thumbnail (${{ matrix.framework }})
run: dotnet run --base "../../../../fileonq.imaging.heif/benchmarks/results/thumbnail.${{ matrix.framework }}" --diff "../../../../artifacts/Benchmark-thumbnail.${{ matrix.framework }}" --threshold 10% --top 10 > thumbnail.${{ matrix.framework }}.output.txt
working-directory: ./dotnet.performance/src/tools/ResultsComparer
- name: Compare - primary (${{ matrix.framework }})
run: dotnet run --base "../../../../fileonq.imaging.heif/benchmarks/results/primary.${{ matrix.framework }}" --diff "../../../../artifacts/Benchmark-primary.${{ matrix.framework }}" --threshold 10% --top 10 > primary.${{ matrix.framework }}.output.txt
working-directory: ./dotnet.performance/src/tools/ResultsComparer
- name: GitHub Comment - Comparison (${{ matrix.framework }})
run: |
$thumbnail = Get-Content "thumbnail.${{ matrix.framework }}.output.txt" -raw
$primary = Get-Content "primary.${{ matrix.framework }}.output.txt" -raw
$message = "## Benchmark Comparison - ${{ matrix.name }}`r`n"
$message += "Benchmarking comparison between this Pull Request and the comitted values at benchmarks/results `r`n`r`n"
$message += "thumbnail`r`n"
$message += "\``\``\``ini `r`n $thumbnail `r`n \``\``\``"
$message += "`r`n`r`nprimary`r`n"
$message += "\``\``\``ini `r`n $primary `r`n \``\``\``"
echo $message
echo "PR_COMMENT_COMPARISON<<EOF" >> $env:GITHUB_ENV
echo "$message" >> $env:GITHUB_ENV
echo "EOF" >> $env:GITHUB_ENV
working-directory: ./dotnet.performance/src/tools/ResultsComparer
- name: GitHub Comment - Benchmark Results (${{ matrix.framework }})
run: |
$thumbnail = Get-Content "Benchmark-thumbnail.${{ matrix.framework }}/FileOnQ.Imaging.Heif.Benchmarks.Thumbnail-report-github.md" -raw
$thumbnail = $thumbnail.replace("``", "\``")
$primary = Get-Content "Benchmark-primary.${{ matrix.framework }}/FileOnQ.Imaging.Heif.Benchmarks.PrimaryImage-report-github.md" -raw
$primary = $primary.replace("``", "\``")
$message = "## Benchmark Results - ${{ matrix.name }}`r`n"
$message += "<details><summary>thumbnail</summary><p>`r`n`r`n $thumbnail </p></details>`r`n"
$message += "<details><summary>primary</summary><p>`r`n`r`n $primary </p></details>`r`n"
echo $message
echo "PR_COMMENT_RESULTS<<EOF" >> $env:GITHUB_ENV
echo "$message" >> $env:GITHUB_ENV
echo "EOF" >> $env:GITHUB_ENV
working-directory: ./artifacts
- name: Combine Message (${{ matrix.framework }})
run: |
$message = "${{ env.PR_COMMENT_COMPARISON }} \r\n\r\n ${{ env.PR_COMMENT_RESULTS }}"
$message = $message.replace("\\\", "\``\``\``")
echo $message > github-comment.${{ matrix.framework }}.md
working-directory: ./artifacts
- name: Upload Results
uses: actions/upload-artifact@v2
with:
name: Benchmark-GitHub-Comment.${{ matrix.framework }}
path: ./artifacts/github-comment.${{ matrix.framework }}.md
benchmark-github-post:
if: ${{ needs.check-command.outputs.benchmark == 'true' || github.EVENT_NAME == 'pull_request_target' }}
needs: benchmark-compare
runs-on: windows-2019
steps:
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Combine GitHub Comments
run: |
$net48 = Get-Content ./Benchmark-GitHub-Comment.net48/github-comment.net48.md -raw
$net5 = Get-Content ./Benchmark-GitHub-Comment.net5.0/github-comment.net5.0.md -raw
$net6 = Get-Content Benchmark-GitHub-Comment.net6.0/github-comment.net6.0.md -raw
$message = "$net48`r`n`r`n$net5`r`n`r`n$net6"
echo $message
echo "GITHUB_COMMENT<<EOF" >> $env:GITHUB_ENV
echo "$message" >> $env:GITHUB_ENV
echo "EOF" >> $env:GITHUB_ENV
working-directory: ./artifacts
- name: GitHub Comment - Post
uses: actions/github-script@v5
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `${{ env.GITHUB_COMMENT }}`
})