Benchmark #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Benchmark | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| benchmark: | |
| type: choice | |
| description: Specify benchmark name to run. Use "*" to run all benchmarks. | |
| default: "*" | |
| options: | |
| - "*" | |
| - "*AdaptiveBenchmark*" | |
| - "*DistributionBenchmark*" | |
| - "*ExchangeBenchmark*" | |
| - "*HeapBenchmark*" | |
| - "*InsertionBenchmark*" | |
| - "*MergeBenchmark*" | |
| - "*NetworkBenchmark*" | |
| - "*PartitionBenchmark*" | |
| - "*SelectionBenchmark*" | |
| - "*TreeBenchmark*" | |
| - "*IntKeyBenchmark*" | |
| - "*StringBenchmark*" | |
| jobs: | |
| benchmark: | |
| permissions: | |
| contents: read | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0 | |
| id: app-token | |
| with: | |
| app-id: ${{ secrets.SYNCED_ACTIONS_BOT_APPID }} | |
| private-key: ${{ secrets.SYNCED_ACTIONS_BOT_PRIVATE_KEY }} | |
| permission-contents: write | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: guitarrapc/actions/.github/actions/setup-dotnet@main | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: dotnet build | |
| run: dotnet build -c Release | |
| - name: benchmark | |
| id: benchmark | |
| run: | | |
| dotnet run -c Release --no-build --no-launch-profile --project ./src/SortAlgorithm.Benchmark/SortAlgorithm.Benchmark.csproj -- --filter "${{ inputs.benchmark }}" | |
| echo "result=success" >> $GITHUB_OUTPUT | |
| - name: Check benchmark result | |
| if: ${{ steps.benchmark.outputs.result != 'success' }} | |
| run: exit 1 | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7.0.0 | |
| with: | |
| name: BenchmarkDotNet.Artifacts | |
| path: BenchmarkDotNet.Artifacts/ | |
| if-no-files-found: error | |
| - name: Output results to JobSummary | |
| run: | | |
| for file in $(find BenchmarkDotNet.Artifacts/results -name "*.md" | head -n 1); do | |
| machine_info=$(sed -n 's/^[[:space:]]*//; /^\|/p' "$file" | grep -v "|") | |
| echo "$machine_info" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| done | |
| for file in $(find BenchmarkDotNet.Artifacts/results -name "*.md" | sort); do | |
| title=$(basename "$file" .md | sed 's/-report-default//g') | |
| content=$(sed -n 's/^[[:space:]]*//; /^\|/p' "$file" | grep "|") | |
| echo "## $title" >> $GITHUB_STEP_SUMMARY | |
| echo "$content" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| done | |
| - name: Update README.md benchmark report link | |
| if: ${{ inputs.benchmark == '*' }} | |
| run: | | |
| sed -E -i 's|(https://github\.com/[^/]+/[^/]+/actions/runs/)[0-9]+|\1${{ github.run_id }}|g' README.md | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git remote set-url origin "https://github-actions:${GITHUB_TOKEN}@github.com/${{ github.repository }}" | |
| git add README.md | |
| git commit -m 'docs: update benchmark report link' -m "updated in run ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ job.check_run_id }}" | |
| git push | |
| env: | |
| GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} |