diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index d3fc7bb..93d1604 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -38,3 +38,32 @@ jobs: run: dotnet build --configuration Release --no-restore - name: Test run: dotnet test --no-restore --verbosity normal + + benchmark-on-pr: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - name: Setup .NET 9 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '9.0.x' + + - name: Ensure results directory exists + run: | + mkdir -p benchmark/Razor.Template.Core.PerfBenchmark/results + touch benchmark/Razor.Template.Core.PerfBenchmark/results/.gitkeep + + - name: Run benchmark + run: dotnet run -c Release --project benchmark/Razor.Template.Core.PerfBenchmark/Razor.Template.Core.PerfBenchmark.csproj + + - name: Commit benchmark results + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add benchmark/Razor.Template.Core.PerfBenchmark/results/ + git commit -m "chore: update benchmark report [skip ci]" || echo "No changes to commit" + git push origin HEAD:${{ github.head_ref }} diff --git a/benchmark/Razor.Template.Core.PerfBenchmark/Program.cs b/benchmark/Razor.Template.Core.PerfBenchmark/Program.cs index b8e2114..2fa7fce 100644 --- a/benchmark/Razor.Template.Core.PerfBenchmark/Program.cs +++ b/benchmark/Razor.Template.Core.PerfBenchmark/Program.cs @@ -1,4 +1,5 @@ -using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Analysers; +using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Configs; using BenchmarkDotNet.Diagnosers; using BenchmarkDotNet.Exporters; @@ -8,6 +9,7 @@ var config = ManualConfig.CreateMinimumViable() .AddExporter(MarkdownExporter.GitHub) + .AddAnalyser(EnvironmentAnalyser.Default) .WithArtifactsPath("."); BenchmarkRunner.Run(config); diff --git a/benchmark/Razor.Template.Core.PerfBenchmark/Razor.Template.Core.PerfBenchmark.csproj b/benchmark/Razor.Template.Core.PerfBenchmark/Razor.Template.Core.PerfBenchmark.csproj index ae08627..88c5df5 100644 --- a/benchmark/Razor.Template.Core.PerfBenchmark/Razor.Template.Core.PerfBenchmark.csproj +++ b/benchmark/Razor.Template.Core.PerfBenchmark/Razor.Template.Core.PerfBenchmark.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net9.0 enable enable diff --git a/benchmark/Razor.Template.Core.PerfBenchmark/results/.gitkeep b/benchmark/Razor.Template.Core.PerfBenchmark/results/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/benchmark/Razor.Template.Core.PerfBenchmark/results/RazorTemplateBenchMark-report-github.md b/benchmark/Razor.Template.Core.PerfBenchmark/results/RazorTemplateBenchMark-report-github.md deleted file mode 100644 index 01783fd..0000000 --- a/benchmark/Razor.Template.Core.PerfBenchmark/results/RazorTemplateBenchMark-report-github.md +++ /dev/null @@ -1,13 +0,0 @@ -``` - -BenchmarkDotNet v0.15.1, Windows 11 (10.0.26100.4349/24H2/2024Update/HudsonValley) -Unknown processor -.NET SDK 9.0.301 - [Host] : .NET 8.0.16 (8.0.1625.21506), X64 RyuJIT AVX2 - DefaultJob : .NET 8.0.16 (8.0.1625.21506), X64 RyuJIT AVX2 - - -``` -| Method | Mean | Error | StdDev | Median | Gen0 | Allocated | -|------------------------- |---------:|---------:|---------:|---------:|-------:|----------:| -| RenderViewWithModelAsync | 29.87 μs | 0.642 μs | 1.778 μs | 29.35 μs | 5.6152 | 23.16 KB |