-
-
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.
Add ResilienceStrategyProviderBenchmark
- Loading branch information
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...ults/Polly.Core.Benchmarks.ResilienceStrategyProviderBenchmark-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 | Gen0 | Allocated | | ||
|--------------- |---------:|---------:|---------:|-------:|----------:| | ||
| Get_Ok | 25.31 ns | 0.463 ns | 0.663 ns | 0.0013 | 32 B | | ||
| Get_Generic_Ok | 58.16 ns | 0.669 ns | 1.001 ns | 0.0013 | 32 B | |
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
26 changes: 26 additions & 0 deletions
26
src/Polly.Core.Benchmarks/ResilienceStrategyProviderBenchmark.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Polly.Core.Benchmarks; | ||
|
||
namespace Polly.Core.Benchmarks; | ||
|
||
public class ResilienceStrategyProviderBenchmark | ||
{ | ||
private ResilienceStrategyProvider<string>? _provider; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
_provider = new ServiceCollection() | ||
.AddResilienceStrategy("dummy", builder => builder.AddTimeout(new TimeoutStrategyOptions())) | ||
.AddResilienceStrategy<string, string>("dummy", builder => builder.AddTimeout(new TimeoutStrategyOptions())) | ||
.BuildServiceProvider() | ||
.GetRequiredService<ResilienceStrategyProvider<string>>(); | ||
} | ||
|
||
[Benchmark] | ||
public void Get_Ok() => _provider!.Get("dummy"); | ||
|
||
[Benchmark] | ||
public void Get_Generic_Ok() => _provider!.Get<string>("dummy"); | ||
} |