Skip to content

Commit 0b16dcd

Browse files
authored
Add benchmark results to API reference docs on version deploy (#226)
- [x] Remove `benchmark` job from `pull-request.yml` - [x] Add `benchmark` job to `release.yml` (same definition, needs `[workflow-variables, build, validate-release]`) - [x] Update `publish-documentation` job in `release.yml` to depend on `benchmark` - [x] In `publish-documentation.yml`: replace inline `dotnet run` execution with `download-artifact` (pattern `benchmark-*`, `merge-multiple: true`) + awk injection into `benchmarks.md`
1 parent 1dd28dd commit 0b16dcd

5 files changed

Lines changed: 67 additions & 39 deletions

File tree

.github/workflows/publish-documentation.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,21 @@ jobs:
9696
run: |
9797
cp -r api-reference/guide api-reference/${{ env.friendly-version }}/guide
9898
99+
- name: 'Download benchmark results'
100+
uses: actions/download-artifact@v8
101+
with:
102+
pattern: benchmark-*
103+
path: /tmp/benchmarks
104+
merge-multiple: true
105+
106+
- name: 'Inject benchmark results into guide for v${{ env.friendly-version }}'
107+
shell: bash
108+
run: |
109+
find /tmp/benchmarks -name "*-report-github.md" | sort | xargs -r cat > /tmp/benchmark_results.md
110+
awk '/{benchmarks_section}/{while((getline line < "/tmp/benchmark_results.md") > 0) print line; close("/tmp/benchmark_results.md"); next} {print}' \
111+
"api-reference/${{ env.friendly-version }}/guide/benchmarks.md" > /tmp/benchmarks.md
112+
mv /tmp/benchmarks.md "api-reference/${{ env.friendly-version }}/guide/benchmarks.md"
113+
99114
- name: 'Discover all versions'
100115
id: discover-versions
101116
shell: bash

.github/workflows/pull-request.yml

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ permissions:
1818
id-token: write
1919
contents: write
2020

21-
concurrency:
22-
group: pull-request-${{ github.head_ref || github.ref }}
21+
concurrency:
22+
group: pull-request-${{ github.head_ref || github.ref }}
2323
cancel-in-progress: true
2424

2525
env:
@@ -189,7 +189,7 @@ jobs:
189189
- name: Pack with .NET
190190
run: |
191191
dotnet pack ${{ vars.SRC_DEFAULT_GLOB_PATTERN }} --configuration ${{ env.build-configuration }} /p:Platform="${{ env.build-platform }}" /p:PackageVersion=${{ env.release-version }} /p:Version=${{ env.assembly-version }} /p:AssemblyInformationalVersion=${{ env.assembly-informational-version }} /p:FileVersion=${{ env.file-version }} --output ${{ runner.temp }}/${{ env.nuget-packages-directory }}
192-
192+
193193
- name: Upload Package
194194
uses: actions/upload-artifact@v7
195195
with:
@@ -239,38 +239,3 @@ jobs:
239239

240240
- name: 'Check for vulnerable packages'
241241
run: dotnet list src/PolylineAlgorithm/PolylineAlgorithm.csproj package --vulnerable --include-transitive
242-
243-
benchmark:
244-
if: ${{ needs.workflow-variables.outputs.is-release == 'true' || vars.BENCHMARKDOTNET_RUN_OVERRIDE == 'true' }}
245-
name: Benchmark with .NET CLI on ${{ matrix.os }}
246-
needs: [workflow-variables, build]
247-
strategy:
248-
matrix:
249-
os: [ubuntu-latest, windows-latest, macos-latest]
250-
runs-on: ${{ matrix.os }}
251-
steps:
252-
- name: 'Checkout ${{ github.head_ref || github.ref }}'
253-
uses: actions/checkout@v6
254-
- name: Install .NET SDK
255-
uses: actions/setup-dotnet@v5
256-
with:
257-
dotnet-version: |
258-
8.x
259-
10.x
260-
- name: Download Build
261-
uses: actions/download-artifact@v8
262-
with:
263-
name: build
264-
- name: Benchmark
265-
working-directory: ${{ vars.BENCHMARKDOTNET_WORKING_DIRECTORY }}
266-
run: dotnet run --configuration ${{ env.build-configuration }} /p:Platform=${{ env.build-platform }} --framework ${{ vars.DEFAULT_BUILD_FRAMEWORK }} --runtimes ${{ vars.BENCHMARKDOTNET_RUNTIMES }} --filter ${{ vars.BENCHMARKDOTNET_FILTER }} --artifacts ${{ runner.temp }}/benchmarks/ --exporters GitHub --memory --iterationTime 100 --join
267-
- name: Upload Benchmark Results
268-
uses: actions/upload-artifact@v7
269-
with:
270-
name: benchmark-${{ matrix.os }}
271-
path: |
272-
${{ runner.temp }}/benchmarks/**/*-report-github.md
273-
- name: Write Benchmark Summary
274-
shell: bash
275-
run: cat **/*-report-github.md > $GITHUB_STEP_SUMMARY
276-
working-directory: ${{ runner.temp }}/benchmarks/

.github/workflows/release.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,44 @@ jobs:
290290
${{ runner.temp }}/${{ env.nuget-packages-directory }}/**/*.nupkg
291291
${{ runner.temp }}/${{ env.nuget-packages-directory }}/**/*.snupkg
292292
293+
benchmark:
294+
name: Benchmark with .NET CLI on ${{ matrix.os }}
295+
needs: [workflow-variables, build, validate-release]
296+
if: ${{ needs.workflow-variables.outputs.is-release == 'true' || vars.BENCHMARKDOTNET_RUN_OVERRIDE == 'true' }}
297+
strategy:
298+
matrix:
299+
os: [ubuntu-latest, windows-latest, macos-latest]
300+
runs-on: ${{ matrix.os }}
301+
steps:
302+
- name: 'Checkout ${{ github.head_ref || github.ref }}'
303+
uses: actions/checkout@v6
304+
- name: Install .NET SDK
305+
uses: actions/setup-dotnet@v5
306+
with:
307+
dotnet-version: |
308+
8.x
309+
10.x
310+
- name: Download Build
311+
uses: actions/download-artifact@v8
312+
with:
313+
name: build
314+
- name: Benchmark
315+
working-directory: ${{ vars.BENCHMARKDOTNET_WORKING_DIRECTORY }}
316+
run: dotnet run --configuration ${{ env.build-configuration }} /p:Platform=${{ env.build-platform }} --framework ${{ vars.DEFAULT_BUILD_FRAMEWORK }} --runtimes ${{ vars.BENCHMARKDOTNET_RUNTIMES }} --filter ${{ vars.BENCHMARKDOTNET_FILTER }} --artifacts ${{ runner.temp }}/benchmarks/ --exporters GitHub --memory --iterationTime 100 --join
317+
- name: Upload Benchmark Results
318+
uses: actions/upload-artifact@v7
319+
with:
320+
name: benchmark-${{ matrix.os }}
321+
path: |
322+
${{ runner.temp }}/benchmarks/**/*-report-github.md
323+
- name: Write Benchmark Summary
324+
shell: bash
325+
run: cat **/*-report-github.md > $GITHUB_STEP_SUMMARY
326+
working-directory: ${{ runner.temp }}/benchmarks/
327+
293328
publish-documentation:
294329
name: 'Publish documentation'
295-
needs: [pack, validate-release, workflow-variables]
330+
needs: [pack, benchmark, validate-release, workflow-variables]
296331
if: ${{ needs.workflow-variables.outputs.is-release == 'true' }}
297332
uses: ./.github/workflows/publish-documentation.yml
298333
permissions:

api-reference/guide/benchmarks.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: Benchmarks
3+
---
4+
# Benchmarks
5+
6+
Performance benchmarks for **PolylineAlgorithm for .NET** measured using [BenchmarkDotNet](https://benchmarkdotnet.org/).
7+
8+
> [!NOTE]
9+
> Benchmarks are generated automatically during the release process. Results may vary depending on hardware and runtime version.
10+
11+
{benchmarks_section}

api-reference/guide/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
href: sample.md
99
- name: FAQ
1010
href: faq.md
11+
- name: Benchmarks
12+
href: benchmarks.md

0 commit comments

Comments
 (0)