-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
71 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
extern alias from_nuget; | ||
extern alias from_project; | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace Stashbox.Benchmarks | ||
{ | ||
[MemoryDiagnoser] | ||
public class ChildContainerBenchmarks | ||
{ | ||
private readonly from_nuget::Stashbox.IStashboxContainer oldContainer = | ||
new from_nuget::Stashbox.StashboxContainer(); | ||
|
||
private readonly from_project::Stashbox.IStashboxContainer newContainer = | ||
new from_project::Stashbox.StashboxContainer(); | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
this.oldContainer.Register<A>() | ||
.Register<B>() | ||
.Register<C>(); | ||
|
||
this.newContainer.Register<A>() | ||
.Register<B>() | ||
.Register<C>(); | ||
} | ||
|
||
[Benchmark(Baseline = true)] | ||
public object Old() | ||
{ | ||
var child = this.oldContainer.CreateChildContainer(); | ||
child.Register<B>(); | ||
return this.oldContainer.Resolve(typeof(A)); | ||
} | ||
|
||
[Benchmark] | ||
public object New() | ||
{ | ||
var child = this.newContainer.CreateChildContainer(); | ||
child.Register<B>(); | ||
return this.newContainer.Resolve(typeof(A)); | ||
} | ||
|
||
class A | ||
{ | ||
public A(B b, C c) | ||
{ } | ||
} | ||
|
||
class B | ||
{ | ||
public B(C c) | ||
{ } | ||
} | ||
|
||
class C { } | ||
} | ||
} |
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
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