Skip to content

Commit

Permalink
Easier benchmarks (#1207)
Browse files Browse the repository at this point in the history
- Add a helper script to run the benchmarks.
- Fix `-- pick` not working.
  • Loading branch information
martincostello committed May 23, 2023
1 parent cc28c5e commit 71b760a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
25 changes: 25 additions & 0 deletions benchmarks.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#! /usr/bin/env pwsh

Param(
[string]$Configuration = "Release",
[switch]$Interactive
)

$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"

Write-Host "Running benchmarks..."

$additionalArgs = @()

if ($Interactive -ne $true) {
$additionalArgs += "--"
$additionalArgs += "--filter"
$additionalArgs += "*"
}

$project = Join-Path "src" "Polly.Core.Benchmarks" "Polly.Core.Benchmarks.csproj"

dotnet run --configuration $Configuration --framework net7.0 --project $project $additionalArgs

exit $LASTEXITCODE
2 changes: 1 addition & 1 deletion src/Polly.Core.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
.AddJob(Job.MediumRun.WithToolchain(InProcessEmitToolchain.Instance))
.AddDiagnoser(MemoryDiagnoser.Default);

BenchmarkRunner.Run(typeof(PollyVersion).Assembly, config);
BenchmarkSwitcher.FromAssembly(typeof(PollyVersion).Assembly).Run(args, config);
12 changes: 6 additions & 6 deletions src/Polly.Core.Benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Benchmarks

To run the benchmarks:
To run the benchmarks, use the `benchmarks.ps1` script in the root of the repository:

``` powershell
# run all benchmarks
dotnet run -c release -f net7.0
# Run all benchmarks
./benchmarks.ps1
# pick benchmarks to run
dotnet run -c release -f net7.0 -- pick
# Pick benchmarks to run
./benchmarks.ps1 -Interactive
```

The benchmark results are stored in [`BenchmarkDotNet.Artifacts/results`](BenchmarkDotNet.Artifacts/results/) folder.

Run the benchmarks when your changes are significant enough to make sense running them. We do not use fixed hardware so your numbers might differ, however the important is the `Ratio` and `Alloc Ratio` which stays around the same or improves (ideally) between runs.
Run the benchmarks when your changes are significant enough to make sense running them. We do not use fixed hardware so your numbers might differ, however the important is the `Ratio` and `Alloc Ratio` which stays around the same or improves (ideally) between runs.

0 comments on commit 71b760a

Please sign in to comment.