Benchmark(TargetFrameworks) #26
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 | |
run-name: Benchmark(${{ inputs.config }}) | |
on: | |
workflow_dispatch: | |
inputs: | |
config: | |
type: choice | |
description: Specify benchmark config key | |
default: Default | |
options: | |
- Default | |
- Test | |
- TargetFrameworks | |
- NuGetVersions | |
- SystemLinq | |
filter: | |
type: string | |
description: Specify benchmark filter text (e,g. Benchmark.ReadMeBenchmark*) | |
default: '*' | |
framework: | |
type: choice | |
description: Specify target framework for benchmark | |
default: net9.0 | |
options: | |
- net9.0 | |
- net10.0 | |
jobs: | |
benchmark: | |
permissions: | |
contents: write | |
runs-on: ubuntu-24.04 | |
timeout-minutes: 360 # Default: 360 minutes | |
steps: | |
- uses: Cysharp/Actions/.github/actions/checkout@main | |
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main | |
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main | |
if: ${{ inputs.framework == 'net10.0' }} | |
with: | |
dotnet-version: 10.0.x | |
- run: dotnet build -c Release | |
- name: Run Benchmarks | |
working-directory: sandbox/Benchmark | |
run: dotnet run -c Release --framework ${{ inputs.framework }} --no-build --no-launch-profile -- --filter "${{ inputs.filter }}" -- ${{ inputs.config }} | |
- name: Upload artifacts | |
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 #v4.6.1 | |
with: | |
name: BenchmarkDotNet.Artifacts | |
path: sandbox/Benchmark/BenchmarkDotNet.Artifacts/ | |
if-no-files-found: error | |
- name: Output results to JobSummary | |
working-directory: sandbox/Benchmark | |
shell: pwsh | |
run: | | |
$items = Get-ChildItem "BenchmarkDotNet.Artifacts/results/*.md" | where Name -ne 'reports.md' | |
foreach($item in $items) { | |
$title = $item.Name | |
$title = $title.Replace('-report-console.md', '') | |
$title = $title.Replace('_Int32_' , '<int>') | |
$title = $title.Replace('_String_', '<string>') | |
$title = $title.Replace('_Double_', '<double>') | |
$content = Get-Content $item.FullName -Raw | |
$tableContent = $content.Substring($content.IndexOf('|')) | |
$tableContent.Replace('<', '<').Replace('>', '>') | |
Write-Output ('## {0}' -f $title) >> $env:GITHUB_STEP_SUMMARY | |
Write-Output $tableContent >> $env:GITHUB_STEP_SUMMARY | |
} | |
- name: Update README.md benchmark report link | |
if: ${{ github.context.repo.owner == 'Cysharp' && github.ref_name == 'main' && inputs.config == 'Default' && inputs.filter == '*' }} | |
shell: pwsh | |
run: | | |
$PSNativeCommandUseErrorActionPreference = $true | |
$md = Get-Content README.md -Raw | |
$md = [regex]::Replace($md, 'https://github.com/Cysharp/ZLinq/actions/runs/([\d]+)', | |
'https://github.com/Cysharp/ZLinq/actions/runs/${{ github.run_id }}') | |
Set-Content -Path README.md -Value $md -Encoding utf8NoBOM | |
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git add README.md | |
git commit -m 'ci: update benchmark report link' | |
git push |