forked from autofac/Autofac
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add a number of decorator-centric tests to demonstrate expected behavior around resolving IEnumerable<T> and T when decorators are in play -- Exposes issue autofac#1113 in a number of skipped tests * Adding a number of benchmarks for SingleInstance registrations with decorators -- Altered base decorator benchmarks to perform multiple iterations to meansure repeats * Benchmark tweaks to fix repetion issue and add lifetime scope to ensure each benchmark iteration actually creates instances on the first Resolve<> for the decorators Co-authored-by: Bryan Dunn <[email protected]> Co-authored-by: Alistair Evans <[email protected]>
- Loading branch information
1 parent
e4f01e1
commit d1f3d7b
Showing
8 changed files
with
507 additions
and
9 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
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
28 changes: 28 additions & 0 deletions
28
bench/Autofac.Benchmarks/Decorators/KeylessNestedSharedInstanceBenchmark.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,28 @@ | ||
using Autofac.Benchmarks.Decorators.Scenario; | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace Autofac.Benchmarks.Decorators | ||
{ | ||
/// <summary> | ||
/// Benchmarks a more complex case of chaining decorators using the new keyless syntax. | ||
/// </summary> | ||
public class KeylessNestedSharedInstanceBenchmark : DecoratorBenchmarkBase<ICommandHandler> | ||
{ | ||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
var builder = new ContainerBuilder(); | ||
|
||
builder.RegisterType<CommandHandlerOne>() | ||
.As<ICommandHandler>() | ||
.InstancePerLifetimeScope(); | ||
builder.RegisterType<CommandHandlerTwo>() | ||
.As<ICommandHandler>() | ||
.InstancePerLifetimeScope(); | ||
builder.RegisterDecorator<CommandHandlerDecoratorOne, ICommandHandler>(); | ||
builder.RegisterDecorator<CommandHandlerDecoratorTwo, ICommandHandler>(); | ||
|
||
this.Container = builder.Build(); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
bench/Autofac.Benchmarks/Decorators/KeylessNestedSharedInstanceLambdaBenchmark.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,30 @@ | ||
using Autofac.Benchmarks.Decorators.Scenario; | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace Autofac.Benchmarks.Decorators | ||
{ | ||
/// <summary> | ||
/// Benchmarks a more complex case of chaining decorators using the new keyless syntax. | ||
/// </summary> | ||
public class KeylessNestedSharedInstanceLambdaBenchmark : DecoratorBenchmarkBase<ICommandHandler> | ||
{ | ||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
var builder = new ContainerBuilder(); | ||
|
||
builder.RegisterType<CommandHandlerOne>() | ||
.As<ICommandHandler>() | ||
.InstancePerLifetimeScope(); | ||
builder.RegisterType<CommandHandlerTwo>() | ||
.As<ICommandHandler>() | ||
.InstancePerLifetimeScope(); | ||
builder.RegisterDecorator<ICommandHandler>( | ||
(c, p, i) => new CommandHandlerDecoratorOne(i)); | ||
builder.RegisterDecorator<ICommandHandler>( | ||
(c, p, i) => new CommandHandlerDecoratorTwo(i)); | ||
|
||
this.Container = builder.Build(); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
bench/Autofac.Benchmarks/Decorators/KeylessSimpleSharedInstanceBenchmark.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 Autofac.Benchmarks.Decorators.Scenario; | ||
using BenchmarkDotNet.Attributes; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Autofac.Benchmarks.Decorators | ||
{ | ||
/// <summary> | ||
/// Benchmarks the shared instance case for decorators using the new keyless syntax. | ||
/// </summary> | ||
public class KeylessSimpleSharedInstanceBenchmark : DecoratorBenchmarkBase<ICommandHandler> | ||
{ | ||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
var builder = new ContainerBuilder(); | ||
builder.RegisterType<CommandHandlerOne>() | ||
.As<ICommandHandler>() | ||
.InstancePerLifetimeScope(); | ||
builder.RegisterType<CommandHandlerTwo>() | ||
.As<ICommandHandler>() | ||
.InstancePerLifetimeScope(); | ||
builder.RegisterDecorator<CommandHandlerDecoratorOne, ICommandHandler>(); | ||
this.Container = builder.Build(); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
bench/Autofac.Benchmarks/Decorators/KeylessSimpleSharedInstanceLambdaBenchmark.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 Autofac.Benchmarks.Decorators.Scenario; | ||
using BenchmarkDotNet.Attributes; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Autofac.Benchmarks.Decorators | ||
{ | ||
/// <summary> | ||
/// Benchmarks the shared instance case for decorators using the new keyless syntax. | ||
/// </summary> | ||
public class KeylessSimpleSharedInstanceLambdaBenchmark : DecoratorBenchmarkBase<ICommandHandler> | ||
{ | ||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
var builder = new ContainerBuilder(); | ||
builder.RegisterType<CommandHandlerOne>() | ||
.As<ICommandHandler>() | ||
.InstancePerLifetimeScope(); | ||
builder.RegisterType<CommandHandlerTwo>() | ||
.As<ICommandHandler>() | ||
.InstancePerLifetimeScope(); | ||
builder.RegisterDecorator<ICommandHandler>((c, p, i) => new CommandHandlerDecoratorOne(i)); | ||
this.Container = builder.Build(); | ||
} | ||
} | ||
} |
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.