Skip to content

Commit

Permalink
Add benchmark workflow (#1455)
Browse files Browse the repository at this point in the history
  • Loading branch information
twsouthwick authored Jun 27, 2023
1 parent a925836 commit 3439cfc
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 3 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Benchmarks
on:
push:
branches:
- master
pull_request:
branches:
- master

permissions:
contents: write
deployments: write

jobs:
benchmark:
name: Run benchmarks
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
- name: Build benchmarks
run: cd test/DocumentFormat.OpenXml.Benchmarks; dotnet build -c RELEASE
shell: pwsh
- name: Run benchmarks
run: cd test/DocumentFormat.OpenXml.Benchmarks; dotnet run -c RELEASE -- results --exporters json --filter '*'
shell: pwsh
- name: List folders
shell: pwsh
run: cd test/DocumentFormat.OpenXml.Benchmarks; ls -recurse
- name: Store Validation
uses: rhysd/github-action-benchmark@v1
with:
name: Validation
tool: 'benchmarkdotnet'
output-file-path: test/DocumentFormat.OpenXml.Benchmarks/results/results/DocumentFormat.OpenXml.Benchmarks.ValidationTests-report-full-compressed.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@twsouthwick'
- name: Store CompiledParticle
uses: rhysd/github-action-benchmark@v1
with:
name: CompiledParticle
tool: 'benchmarkdotnet'
output-file-path: test/DocumentFormat.OpenXml.Benchmarks/results/results/DocumentFormat.OpenXml.Benchmarks.CompiledParticle-report-full-compressed.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@twsouthwick'
- name: Store Documents
uses: rhysd/github-action-benchmark@v1
with:
name: Documents
tool: 'benchmarkdotnet'
output-file-path: test/DocumentFormat.OpenXml.Benchmarks/results/results/DocumentFormat.OpenXml.Benchmarks.Documents-report-full-compressed.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@twsouthwick'
- name: Store ElementMetadataTests
uses: rhysd/github-action-benchmark@v1
with:
name: ElementMetadataTests
tool: 'benchmarkdotnet'
output-file-path: test/DocumentFormat.OpenXml.Benchmarks/results/results/DocumentFormat.OpenXml.Benchmarks.ElementMetadataTests-report-full-compressed.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@twsouthwick'

7 changes: 4 additions & 3 deletions test/DocumentFormat.OpenXml.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Exporters.Json;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Running;
Expand All @@ -23,7 +24,9 @@ public static void Main(string[] input)
var switcher = new BenchmarkSwitcher(typeof(Program).Assembly);
var config = GetConfig(input);

switcher.Run(new[] { "--filter", "*" }, config);
var args = input.Length == 0 ? new[] { "--filter", "*" } : input;

switcher.Run(args, config);
}

private static IConfig GetConfig(string[] args)
Expand Down Expand Up @@ -56,8 +59,6 @@ public CustomConfig()
// Exporters
AddExporter(AsciiDocExporter.Default);
AddExporter(HtmlExporter.Default);

AddJob(Job.InProcess);
}
}
}
Expand Down

0 comments on commit 3439cfc

Please sign in to comment.