-
-
Notifications
You must be signed in to change notification settings - Fork 833
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1116 from VonOgre/feature/benchmarks
Expanded Decorator Benchmarks and tests for #1113
- Loading branch information
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.