diff --git a/.github/workflows/publish-documentation.yml b/.github/workflows/publish-documentation.yml index 474910ff..7f01504d 100644 --- a/.github/workflows/publish-documentation.yml +++ b/.github/workflows/publish-documentation.yml @@ -96,6 +96,21 @@ jobs: run: | cp -r api-reference/guide api-reference/${{ env.friendly-version }}/guide + - name: 'Download benchmark results' + uses: actions/download-artifact@v8 + with: + pattern: benchmark-* + path: /tmp/benchmarks + merge-multiple: true + + - name: 'Inject benchmark results into guide for v${{ env.friendly-version }}' + shell: bash + run: | + find /tmp/benchmarks -name "*-report-github.md" | sort | xargs -r cat > /tmp/benchmark_results.md + awk '/{benchmarks_section}/{while((getline line < "/tmp/benchmark_results.md") > 0) print line; close("/tmp/benchmark_results.md"); next} {print}' \ + "api-reference/${{ env.friendly-version }}/guide/benchmarks.md" > /tmp/benchmarks.md + mv /tmp/benchmarks.md "api-reference/${{ env.friendly-version }}/guide/benchmarks.md" + - name: 'Discover all versions' id: discover-versions shell: bash diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index bffc605e..c99f254d 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -18,8 +18,8 @@ permissions: id-token: write contents: write -concurrency: - group: pull-request-${{ github.head_ref || github.ref }} +concurrency: + group: pull-request-${{ github.head_ref || github.ref }} cancel-in-progress: true env: @@ -189,7 +189,7 @@ jobs: - name: Pack with .NET run: | 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 }} - + - name: Upload Package uses: actions/upload-artifact@v7 with: @@ -239,38 +239,3 @@ jobs: - name: 'Check for vulnerable packages' run: dotnet list src/PolylineAlgorithm/PolylineAlgorithm.csproj package --vulnerable --include-transitive - - benchmark: - if: ${{ needs.workflow-variables.outputs.is-release == 'true' || vars.BENCHMARKDOTNET_RUN_OVERRIDE == 'true' }} - name: Benchmark with .NET CLI on ${{ matrix.os }} - needs: [workflow-variables, build] - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - runs-on: ${{ matrix.os }} - steps: - - name: 'Checkout ${{ github.head_ref || github.ref }}' - uses: actions/checkout@v6 - - name: Install .NET SDK - uses: actions/setup-dotnet@v5 - with: - dotnet-version: | - 8.x - 10.x - - name: Download Build - uses: actions/download-artifact@v8 - with: - name: build - - name: Benchmark - working-directory: ${{ vars.BENCHMARKDOTNET_WORKING_DIRECTORY }} - 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 - - name: Upload Benchmark Results - uses: actions/upload-artifact@v7 - with: - name: benchmark-${{ matrix.os }} - path: | - ${{ runner.temp }}/benchmarks/**/*-report-github.md - - name: Write Benchmark Summary - shell: bash - run: cat **/*-report-github.md > $GITHUB_STEP_SUMMARY - working-directory: ${{ runner.temp }}/benchmarks/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 466b6240..b0bd5699 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -290,9 +290,44 @@ jobs: ${{ runner.temp }}/${{ env.nuget-packages-directory }}/**/*.nupkg ${{ runner.temp }}/${{ env.nuget-packages-directory }}/**/*.snupkg + benchmark: + name: Benchmark with .NET CLI on ${{ matrix.os }} + needs: [workflow-variables, build, validate-release] + if: ${{ needs.workflow-variables.outputs.is-release == 'true' || vars.BENCHMARKDOTNET_RUN_OVERRIDE == 'true' }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - name: 'Checkout ${{ github.head_ref || github.ref }}' + uses: actions/checkout@v6 + - name: Install .NET SDK + uses: actions/setup-dotnet@v5 + with: + dotnet-version: | + 8.x + 10.x + - name: Download Build + uses: actions/download-artifact@v8 + with: + name: build + - name: Benchmark + working-directory: ${{ vars.BENCHMARKDOTNET_WORKING_DIRECTORY }} + 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 + - name: Upload Benchmark Results + uses: actions/upload-artifact@v7 + with: + name: benchmark-${{ matrix.os }} + path: | + ${{ runner.temp }}/benchmarks/**/*-report-github.md + - name: Write Benchmark Summary + shell: bash + run: cat **/*-report-github.md > $GITHUB_STEP_SUMMARY + working-directory: ${{ runner.temp }}/benchmarks/ + publish-documentation: name: 'Publish documentation' - needs: [pack, validate-release, workflow-variables] + needs: [pack, benchmark, validate-release, workflow-variables] if: ${{ needs.workflow-variables.outputs.is-release == 'true' }} uses: ./.github/workflows/publish-documentation.yml permissions: diff --git a/api-reference/guide/benchmarks.md b/api-reference/guide/benchmarks.md new file mode 100644 index 00000000..47b453f9 --- /dev/null +++ b/api-reference/guide/benchmarks.md @@ -0,0 +1,11 @@ +--- +title: Benchmarks +--- +# Benchmarks + +Performance benchmarks for **PolylineAlgorithm for .NET** measured using [BenchmarkDotNet](https://benchmarkdotnet.org/). + +> [!NOTE] +> Benchmarks are generated automatically during the release process. Results may vary depending on hardware and runtime version. + +{benchmarks_section} diff --git a/api-reference/guide/toc.yml b/api-reference/guide/toc.yml index 015a9943..e9d9e716 100644 --- a/api-reference/guide/toc.yml +++ b/api-reference/guide/toc.yml @@ -8,3 +8,5 @@ href: sample.md - name: FAQ href: faq.md +- name: Benchmarks + href: benchmarks.md