-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upload benchmark results * New benchmark and simplify running them * Clenaup * re-upload benchmarks
- Loading branch information
Showing
30 changed files
with
230 additions
and
106 deletions.
There are no files selected for viewing
This file contains 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
15 changes: 15 additions & 0 deletions
15
...rtifacts/results/Polly.Core.Benchmarks.CircuitBreakerBenchmark-report-github.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
``` ini | ||
|
||
BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1702/22H2/2022Update/SunValley2), VM=Hyper-V | ||
Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores | ||
.NET SDK=7.0.302 | ||
[Host] : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2 | ||
|
||
Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 | ||
LaunchCount=2 WarmupCount=10 | ||
|
||
``` | ||
| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | | ||
|------------------------- |---------:|--------:|--------:|------:|--------:|-------:|----------:|------------:| | ||
| ExecuteCircuitBreaker_V7 | 314.0 ns | 3.45 ns | 4.94 ns | 1.00 | 0.00 | 0.0200 | 504 B | 1.00 | | ||
| ExecuteCircuitBreaker_V8 | 468.3 ns | 1.83 ns | 2.51 ns | 1.49 | 0.03 | 0.0010 | 32 B | 0.06 | |
15 changes: 15 additions & 0 deletions
15
...tifacts/results/Polly.Core.Benchmarks.GenericOverheadBenchmark-report-github.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
``` ini | ||
|
||
BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1702/22H2/2022Update/SunValley2), VM=Hyper-V | ||
Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores | ||
.NET SDK=7.0.302 | ||
[Host] : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2 | ||
|
||
Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 | ||
LaunchCount=2 WarmupCount=10 | ||
|
||
``` | ||
| Method | Mean | Error | StdDev | Ratio | RatioSD | Allocated | Alloc Ratio | | ||
|------------------------ |---------:|---------:|---------:|------:|--------:|----------:|------------:| | ||
| ExecuteAsync_Generic | 29.58 ns | 0.103 ns | 0.155 ns | 1.00 | 0.00 | - | NA | | ||
| ExecuteAsync_NonGeneric | 32.72 ns | 0.334 ns | 0.490 ns | 1.11 | 0.02 | - | NA | |
17 changes: 17 additions & 0 deletions
17
...otNet.Artifacts/results/Polly.Core.Benchmarks.HedgingBenchmark-report-github.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
``` ini | ||
|
||
BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1702/22H2/2022Update/SunValley2), VM=Hyper-V | ||
Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores | ||
.NET SDK=7.0.302 | ||
[Host] : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2 | ||
|
||
Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 | ||
LaunchCount=2 WarmupCount=10 | ||
|
||
``` | ||
| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Gen1 | Allocated | Alloc Ratio | | ||
|---------------------------- |-----------:|----------:|----------:|------:|--------:|-------:|-------:|----------:|------------:| | ||
| Hedging_Primary | 958.3 ns | 4.36 ns | 6.52 ns | 1.00 | 0.00 | 0.0019 | - | 80 B | 1.00 | | ||
| Hedging_Secondary | 1,817.0 ns | 11.59 ns | 17.35 ns | 1.90 | 0.01 | 0.0095 | - | 280 B | 3.50 | | ||
| Hedging_Primary_AsyncWork | 5,000.9 ns | 164.21 ns | 235.50 ns | 5.21 | 0.23 | 0.0458 | 0.0229 | 1244 B | 15.55 | | ||
| Hedging_Secondary_AsyncWork | 7,898.5 ns | 181.13 ns | 271.10 ns | 8.24 | 0.26 | 0.0687 | 0.0610 | 1755 B | 21.94 | |
15 changes: 15 additions & 0 deletions
15
...acts/results/Polly.Core.Benchmarks.MultipleStrategiesBenchmark-report-github.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
``` ini | ||
|
||
BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1702/22H2/2022Update/SunValley2), VM=Hyper-V | ||
Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores | ||
.NET SDK=7.0.302 | ||
[Host] : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2 | ||
|
||
Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 | ||
LaunchCount=2 WarmupCount=10 | ||
|
||
``` | ||
| Method | Mean | Error | StdDev | Ratio | Gen0 | Allocated | Alloc Ratio | | ||
|--------------------------- |---------:|----------:|----------:|------:|-------:|----------:|------------:| | ||
| ExecuteStrategyPipeline_V7 | 2.275 μs | 0.0221 μs | 0.0309 μs | 1.00 | 0.1106 | 2824 B | 1.00 | | ||
| ExecuteStrategyPipeline_V8 | 1.759 μs | 0.0078 μs | 0.0114 μs | 0.77 | 0.0019 | 72 B | 0.03 | |
24 changes: 24 additions & 0 deletions
24
...tNet.Artifacts/results/Polly.Core.Benchmarks.PipelineBenchmark-report-github.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
``` ini | ||
|
||
BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1702/22H2/2022Update/SunValley2), VM=Hyper-V | ||
Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores | ||
.NET SDK=7.0.302 | ||
[Host] : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2 | ||
|
||
Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 | ||
LaunchCount=2 WarmupCount=10 | ||
|
||
``` | ||
| Method | Components | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | | ||
|------------------- |----------- |-----------:|---------:|---------:|------:|--------:|-------:|----------:|------------:| | ||
| **ExecutePipeline_V7** | **1** | **112.6 ns** | **3.90 ns** | **5.83 ns** | **1.00** | **0.00** | **0.0120** | **304 B** | **1.00** | | ||
| ExecutePipeline_V8 | 1 | 114.7 ns | 1.43 ns | 2.14 ns | 1.02 | 0.06 | - | - | 0.00 | | ||
| | | | | | | | | | | | ||
| **ExecutePipeline_V7** | **2** | **281.6 ns** | **4.78 ns** | **7.15 ns** | **1.00** | **0.00** | **0.0219** | **552 B** | **1.00** | | ||
| ExecutePipeline_V8 | 2 | 155.8 ns | 1.00 ns | 1.50 ns | 0.55 | 0.02 | - | - | 0.00 | | ||
| | | | | | | | | | | | ||
| **ExecutePipeline_V7** | **5** | **921.0 ns** | **6.42 ns** | **9.00 ns** | **1.00** | **0.00** | **0.0515** | **1296 B** | **1.00** | | ||
| ExecutePipeline_V8 | 5 | 346.5 ns | 1.09 ns | 1.53 ns | 0.38 | 0.00 | - | - | 0.00 | | ||
| | | | | | | | | | | | ||
| **ExecutePipeline_V7** | **10** | **1,982.9 ns** | **63.37 ns** | **86.74 ns** | **1.00** | **0.00** | **0.0992** | **2536 B** | **1.00** | | ||
| ExecutePipeline_V8 | 10 | 610.2 ns | 3.49 ns | 5.01 ns | 0.31 | 0.01 | - | - | 0.00 | |
15 changes: 15 additions & 0 deletions
15
...t.Artifacts/results/Polly.Core.Benchmarks.RateLimiterBenchmark-report-github.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
``` ini | ||
|
||
BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1702/22H2/2022Update/SunValley2), VM=Hyper-V | ||
Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores | ||
.NET SDK=7.0.302 | ||
[Host] : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2 | ||
|
||
Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 | ||
LaunchCount=2 WarmupCount=10 | ||
|
||
``` | ||
| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | | ||
|---------------------- |---------:|--------:|--------:|------:|--------:|-------:|----------:|------------:| | ||
| ExecuteRateLimiter_V7 | 250.8 ns | 3.45 ns | 5.06 ns | 1.00 | 0.00 | 0.0148 | 376 B | 1.00 | | ||
| ExecuteRateLimiter_V8 | 264.8 ns | 1.69 ns | 2.48 ns | 1.06 | 0.03 | 0.0014 | 40 B | 0.11 | |
16 changes: 16 additions & 0 deletions
16
...acts/results/Polly.Core.Benchmarks.ResilienceStrategyBenchmark-report-github.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
``` ini | ||
|
||
BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1702/22H2/2022Update/SunValley2), VM=Hyper-V | ||
Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores | ||
.NET SDK=7.0.302 | ||
[Host] : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2 | ||
|
||
Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 | ||
LaunchCount=2 WarmupCount=10 | ||
|
||
``` | ||
| Method | Mean | Error | StdDev | Ratio | RatioSD | Allocated | Alloc Ratio | | ||
|----------------------------------------------- |----------:|---------:|---------:|------:|--------:|----------:|------------:| | ||
| ExecuteAsync_ResilienceContextAndState | 67.14 ns | 0.473 ns | 0.708 ns | 1.00 | 0.00 | - | NA | | ||
| ExecuteAsync_CancellationToken | 115.73 ns | 0.874 ns | 1.253 ns | 1.72 | 0.01 | - | NA | | ||
| ExecuteAsync_GenericStrategy_CancellationToken | 117.85 ns | 0.346 ns | 0.486 ns | 1.76 | 0.02 | - | NA | |
15 changes: 15 additions & 0 deletions
15
...kDotNet.Artifacts/results/Polly.Core.Benchmarks.RetryBenchmark-report-github.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
``` ini | ||
|
||
BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1702/22H2/2022Update/SunValley2), VM=Hyper-V | ||
Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores | ||
.NET SDK=7.0.302 | ||
[Host] : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2 | ||
|
||
Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 | ||
LaunchCount=2 WarmupCount=10 | ||
|
||
``` | ||
| Method | Mean | Error | StdDev | Median | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | | ||
|---------------- |---------:|--------:|--------:|---------:|------:|--------:|-------:|----------:|------------:| | ||
| ExecuteRetry_V7 | 247.8 ns | 5.90 ns | 8.64 ns | 250.1 ns | 1.00 | 0.00 | 0.0219 | 552 B | 1.00 | | ||
| ExecuteRetry_V8 | 203.2 ns | 0.74 ns | 1.01 ns | 203.9 ns | 0.82 | 0.03 | - | - | 0.00 | |
15 changes: 15 additions & 0 deletions
15
...otNet.Artifacts/results/Polly.Core.Benchmarks.TimeoutBenchmark-report-github.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
``` ini | ||
|
||
BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1702/22H2/2022Update/SunValley2), VM=Hyper-V | ||
Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores | ||
.NET SDK=7.0.302 | ||
[Host] : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2 | ||
|
||
Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 | ||
LaunchCount=2 WarmupCount=10 | ||
|
||
``` | ||
| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | | ||
|------------------ |---------:|--------:|--------:|------:|--------:|-------:|----------:|------------:| | ||
| ExecuteTimeout_V7 | 386.1 ns | 2.23 ns | 3.33 ns | 1.00 | 0.00 | 0.0286 | 728 B | 1.00 | | ||
| ExecuteTimeout_V8 | 300.2 ns | 4.65 ns | 6.95 ns | 0.78 | 0.02 | - | - | 0.00 | |
3 changes: 1 addition & 2 deletions
3
...rks/Benchmarks/CircuitBreakerBenchmark.cs → ...ore.Benchmarks/CircuitBreakerBenchmark.cs
This file contains 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
This file contains 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
This file contains 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
3 changes: 1 addition & 2 deletions
3
...s/Benchmarks/StrategyPipelineBenchmark.cs → ...Benchmarks/MultipleStrategiesBenchmark.cs
This file contains 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
1 change: 0 additions & 1 deletion
1
...enchmarks/Benchmarks/PipelineBenchmark.cs → ...olly.Core.Benchmarks/PipelineBenchmark.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using Polly; | ||
|
||
namespace Polly.Core.Benchmarks; | ||
|
||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,15 @@ | ||
# Benchmark results | ||
# Benchmarks | ||
|
||
```text | ||
BenchmarkDotNet=v0.13.3, OS=Windows 11 (10.0.22621.1413) | ||
Intel Core i9-10885H CPU 2.40GHz, 1 CPU, 16 logical and 8 physical cores | ||
.NET SDK=7.0.202 | ||
[Host] : .NET 7.0.4 (7.0.423.11508), X64 RyuJIT AVX2 | ||
To run the benchmarks: | ||
|
||
Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 | ||
LaunchCount=2 WarmupCount=10 | ||
``` | ||
|
||
## Genric vs Non-Generic classes | ||
|
||
This benchmark demonstrates that impact of having non-generic `ResilienceStrategy` is minimal. | ||
|
||
| Method | Mean | Error | StdDev | Ratio | Allocated | Alloc Ratio | | ||
|------------------------ |---------:|---------:|---------:|------:|----------:|------------:| | ||
| ExecuteAsync_Generic | 30.25 ns | 0.197 ns | 0.269 ns | 1.00 | - | NA | | ||
| ExecuteAsync_NonGeneric | 32.02 ns | 0.071 ns | 0.094 ns | 1.06 | - | NA | | ||
|
||
|
||
## PIPELINES | ||
|
||
| Method | Components | Mean | Error | StdDev | Median | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | | ||
|------------------- |----------- |------------:|----------:|-----------:|------------:|------:|--------:|-------:|----------:|------------:| | ||
| ExecutePipeline_V7 | 1 | 74.78 ns | 1.555 ns | 2.279 ns | 75.63 ns | 1.00 | 0.00 | 0.0362 | 304 B | 1.00 | | ||
| ExecutePipeline_V8 | 1 | 85.69 ns | 0.500 ns | 0.732 ns | 85.36 ns | 1.15 | 0.04 | - | - | 0.00 | | ||
| | | | | | | | | | | | | ||
| ExecutePipeline_V7 | 2 | 165.37 ns | 1.157 ns | 1.732 ns | 165.59 ns | 1.00 | 0.00 | 0.0658 | 552 B | 1.00 | | ||
| ExecutePipeline_V8 | 2 | 119.10 ns | 0.653 ns | 0.915 ns | 119.63 ns | 0.72 | 0.01 | - | - | 0.00 | | ||
| | | | | | | | | | | | | ||
| ExecutePipeline_V7 | 5 | 533.97 ns | 7.327 ns | 10.967 ns | 536.79 ns | 1.00 | 0.00 | 0.1545 | 1296 B | 1.00 | | ||
| ExecutePipeline_V8 | 5 | 227.69 ns | 1.236 ns | 1.812 ns | 227.72 ns | 0.43 | 0.01 | - | - | 0.00 | | ||
| | | | | | | | | | | | | ||
| ExecutePipeline_V7 | 10 | 1,191.41 ns | 35.512 ns | 53.152 ns | 1,192.79 ns | 1.00 | 0.00 | 0.3014 | 2536 B | 1.00 | | ||
| ExecutePipeline_V8 | 10 | 557.95 ns | 76.434 ns | 112.036 ns | 505.58 ns | 0.47 | 0.09 | - | - | 0.00 | | ||
|
||
## TIMEOUT | ||
|
||
| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | | ||
|------------------ |---------:|--------:|---------:|------:|--------:|-------:|----------:|------------:| | ||
| ExecuteTimeout_V7 | 304.9 ns | 7.53 ns | 11.27 ns | 1.00 | 0.00 | 0.0868 | 728 B | 1.00 | | ||
| ExecuteTimeout_V8 | 266.5 ns | 5.95 ns | 8.72 ns | 0.88 | 0.04 | - | - | 0.00 | | ||
``` powershell | ||
# run all benchmarks | ||
dotnet run -c release -f net7.0 | ||
## RETRY | ||
|
||
| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | | ||
|---------------- |---------:|--------:|--------:|------:|--------:|-------:|----------:|------------:| | ||
| ExecuteRetry_V7 | 169.8 ns | 4.98 ns | 6.98 ns | 1.00 | 0.00 | 0.0687 | 576 B | 1.00 | | ||
| ExecuteRetry_V8 | 144.9 ns | 2.35 ns | 3.52 ns | 0.85 | 0.04 | - | - | 0.00 | | ||
|
||
## RATE LIMITER | ||
|
||
| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | | ||
|---------------------- |---------:|---------:|---------:|------:|--------:|-------:|----------:|------------:| | ||
| ExecuteRateLimiter_V7 | 190.8 ns | 10.01 ns | 14.98 ns | 1.00 | 0.00 | 0.0448 | 376 B | 1.00 | | ||
| ExecuteRateLimiter_V8 | 199.6 ns | 2.54 ns | 3.64 ns | 1.05 | 0.09 | 0.0048 | 40 B | 0.11 | | ||
|
||
## CIRCUIT BREAKER | ||
|
||
| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | | ||
|------------------------- |---------:|--------:|--------:|------:|--------:|-------:|----------:|------------:| | ||
| ExecuteCircuitBreaker_V7 | 198.4 ns | 2.78 ns | 3.99 ns | 1.00 | 0.00 | 0.0629 | 528 B | 1.00 | | ||
| ExecuteCircuitBreaker_V8 | 297.9 ns | 2.63 ns | 3.77 ns | 1.50 | 0.04 | 0.0038 | 32 B | 0.06 | | ||
|
||
## STRATEGY PIPELINE (RATE LIMITER + TIMEOUT + RETRY + TIMEOUT + CIRCUIT BREAKER) | ||
|
||
| Method | Mean | Error | StdDev | Ratio | Gen0 | Allocated | Alloc Ratio | | ||
|--------------------------- |---------:|----------:|----------:|------:|-------:|----------:|------------:| | ||
| ExecuteStrategyPipeline_V7 | 1.523 us | 0.0092 us | 0.0137 us | 1.00 | 0.3433 | 2872 B | 1.00 | | ||
| ExecuteStrategyPipeline_V8 | 1.276 us | 0.0128 us | 0.0191 us | 0.84 | 0.0114 | 96 B | 0.03 | | ||
# pick benchmarks to run | ||
dotnet run -c release -f net7.0 -- pick | ||
``` | ||
|
||
## HEDGING | ||
The benchmark results are stored in [`BenchmarkDotNet.Artifacts/results`](BenchmarkDotNet.Artifacts/results/) folder. | ||
|
||
| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Gen1 | Allocated | Alloc Ratio | | ||
|---------------------------- |-----------:|----------:|----------:|------:|--------:|-------:|-------:|----------:|------------:| | ||
| Hedging_Primary | 891.3 ns | 39.39 ns | 58.96 ns | 1.00 | 0.00 | 0.0048 | - | 40 B | 1.00 | | ||
| Hedging_Secondary | 1,500.0 ns | 7.88 ns | 11.80 ns | 1.69 | 0.11 | 0.0229 | - | 200 B | 5.00 | | ||
| Hedging_Primary_AsyncWork | 4,250.9 ns | 140.89 ns | 206.52 ns | 4.78 | 0.34 | 0.1831 | 0.0305 | 1518 B | 37.95 | | ||
| Hedging_Secondary_AsyncWork | 6,544.9 ns | 99.90 ns | 143.27 ns | 7.34 | 0.39 | 0.2213 | 0.0839 | 1872 B | 46.80 | | ||
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. |
3 changes: 1 addition & 2 deletions
3
...hmarks/Benchmarks/RateLimiterBenchmark.cs → ...y.Core.Benchmarks/RateLimiterBenchmark.cs
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Threading.Tasks; | ||
using BenchmarkDotNet.Attributes; | ||
using Polly.Strategy; | ||
|
||
namespace Polly.Core.Benchmarks; | ||
|
||
public class ResilienceStrategyBenchmark | ||
{ | ||
private readonly DummyResilienceStrategy _strategy = new(); | ||
private readonly ResilienceStrategy<string> _genericStrategy = NullResilienceStrategy<string>.Instance; | ||
|
||
[Benchmark(Baseline = true)] | ||
public async ValueTask ExecuteAsync_ResilienceContextAndState() | ||
{ | ||
var context = ResilienceContext.Get(); | ||
await _strategy.ExecuteAsync((_, _) => new ValueTask<Outcome<string>>(new Outcome<string>("dummy")), context, "state").ConfigureAwait(false); | ||
ResilienceContext.Return(context); | ||
} | ||
|
||
[Benchmark] | ||
public async ValueTask ExecuteAsync_CancellationToken() | ||
{ | ||
await _strategy.ExecuteAsync(_ => new ValueTask<string>("dummy"), CancellationToken.None).ConfigureAwait(false); | ||
} | ||
|
||
[Benchmark] | ||
public async ValueTask ExecuteAsync_GenericStrategy_CancellationToken() | ||
{ | ||
await _genericStrategy.ExecuteAsync(_ => new ValueTask<string>("dummy"), CancellationToken.None).ConfigureAwait(false); | ||
} | ||
|
||
private class DummyResilienceStrategy : ResilienceStrategy | ||
{ | ||
protected override ValueTask<TResult> ExecuteCoreAsync<TResult, TState>( | ||
Func<ResilienceContext, TState, ValueTask<TResult>> callback, | ||
ResilienceContext context, | ||
TState state) => callback(context, state); | ||
} | ||
|
||
public class NonGenericStrategy | ||
{ | ||
[MethodImpl(MethodImplOptions.NoOptimization)] | ||
public virtual ValueTask<T> ExecuteAsync<T>(Func<ValueTask<T>> callback) | ||
{ | ||
return callback(); | ||
} | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
...e.Benchmarks/Benchmarks/RetryBenchmark.cs → src/Polly.Core.Benchmarks/RetryBenchmark.cs
This file contains 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
Oops, something went wrong.