-
-
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 a benchmark for `CompositeComponent` to aid with #1732.
- Loading branch information
1 parent
63ec704
commit a0e30b0
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
...acts/results/Polly.Core.Benchmarks.CompositeComponentBenchmark-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,14 @@ | ||
``` | ||
BenchmarkDotNet v0.13.9+228a464e8be6c580ad9408e98f18813f6407fb5a, Windows 11 (10.0.22621.2428/22H2/2022Update/SunValley2) | ||
12th Gen Intel Core i7-1270P, 1 CPU, 16 logical and 12 physical cores | ||
.NET SDK 7.0.403 | ||
[Host] : .NET 7.0.13 (7.0.1323.51816), X64 RyuJIT AVX2 | ||
Job=MediumRun Toolchain=InProcessEmitToolchain IterationCount=15 | ||
LaunchCount=2 WarmupCount=10 | ||
``` | ||
| Method | Mean | Error | StdDev | Allocated | | ||
|------------------------------- |---------:|---------:|---------:|----------:| | ||
| CompositeComponent_ExecuteCore | 44.37 ns | 1.994 ns | 2.923 ns | - | |
27 changes: 27 additions & 0 deletions
27
bench/Polly.Core.Benchmarks/CompositeComponentBenchmark.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,27 @@ | ||
using Polly.Telemetry; | ||
using Polly.Utils.Pipeline; | ||
|
||
namespace Polly.Core.Benchmarks; | ||
|
||
public class CompositeComponentBenchmark | ||
{ | ||
private ResilienceContext? _context; | ||
private PipelineComponent? _component; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
var first = PipelineComponent.Empty; | ||
var second = PipelineComponent.Empty; | ||
var source = new ResilienceTelemetrySource("pipeline", "instance", "strategy"); | ||
var telemetry = new ResilienceStrategyTelemetry(source, null); | ||
var components = new[] { first, second }; | ||
|
||
_component = CompositeComponent.Create(components, telemetry, TimeProvider.System); | ||
_context = ResilienceContextPool.Shared.Get(); | ||
} | ||
|
||
[Benchmark] | ||
public ValueTask<Outcome<int>> CompositeComponent_ExecuteCore() | ||
=> _component!.ExecuteCore((_, state) => Outcome.FromResultAsValueTask(state), _context!, 42); | ||
} |