-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGetGraph50.cs
More file actions
165 lines (154 loc) · 7.93 KB
/
GetGraph50.cs
File metadata and controls
165 lines (154 loc) · 7.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
namespace Gu.Inject.Benchmarks
{
using BenchmarkDotNet.Attributes;
using DryIoc;
using Ninject;
using SimpleInjector;
using static Gu.Inject.Benchmarks.Types.Graph50;
[MemoryDiagnoser]
public class GetGraph50
{
private static readonly Ninject.StandardKernel StandardKernel = new(new Module());
private static readonly SimpleInjector.Container SimpleInjectorContainer = new()
{
Options =
{
ResolveUnregisteredConcreteTypes = true,
DefaultLifestyle = Lifestyle.Singleton,
},
};
private static readonly DryIoc.Container DryIocContainer = new(x => x.WithConcreteTypeDynamicRegistrations()
.WithDefaultReuse(Reuse.Singleton));
private static readonly Kernel Kernel = new();
private static readonly Kernel BoundKernel = new Kernel()
.Bind(c => new Node1(c.Get<Node2>(), c.Get<Node7>(), c.Get<Node10>(), c.Get<Node16>(), c.Get<Node18>(), c.Get<Node24>(), c.Get<Node26>(), c.Get<Node27>(), c.Get<Node29>(), c.Get<Node32>()))
.Bind(c => new Node2(c.Get<Node4>(), c.Get<Node8>(), c.Get<Node16>(), c.Get<Node48>()))
.Bind(c => new Node3(c.Get<Node33>()))
.Bind(c => new Node4(c.Get<Node8>(), c.Get<Node32>(), c.Get<Node36>()))
.Bind(c => new Node5(c.Get<Node30>()))
.Bind(c => new Node6(c.Get<Node18>(), c.Get<Node30>()))
.Bind(c => new Node7(c.Get<Node35>(), c.Get<Node49>()))
.Bind(c => new Node8())
.Bind(c => new Node9(c.Get<Node18>()))
.Bind(c => new Node10())
.Bind(c => new Node11(c.Get<Node22>()))
.Bind(c => new Node12(c.Get<Node24>(), c.Get<Node48>()))
.Bind(c => new Node13(c.Get<Node39>()))
.Bind(c => new Node14(c.Get<Node28>()))
.Bind(c => new Node15(c.Get<Node30>()))
.Bind(c => new Node16())
.Bind(c => new Node17())
.Bind(c => new Node18())
.Bind(c => new Node19())
.Bind(c => new Node20())
.Bind(c => new Node21())
.Bind(c => new Node22())
.Bind(c => new Node23())
.Bind(c => new Node24(c.Get<Node48>()))
.Bind(c => new Node25())
.Bind(c => new Node26())
.Bind(c => new Node27())
.Bind(c => new Node28())
.Bind(c => new Node29())
.Bind(c => new Node30())
.Bind(c => new Node31())
.Bind(c => new Node32())
.Bind(c => new Node33())
.Bind(c => new Node34())
.Bind(c => new Node35())
.Bind(c => new Node36())
.Bind(c => new Node37())
.Bind(c => new Node38())
.Bind(c => new Node39())
.Bind(c => new Node40())
.Bind(c => new Node41())
.Bind(c => new Node42())
.Bind(c => new Node43())
.Bind(c => new Node44())
.Bind(c => new Node45())
.Bind(c => new Node46())
.Bind(c => new Node47())
.Bind(c => new Node48())
.Bind(c => new Node49());
[Benchmark]
public object Ninject()
{
return StandardKernel.Get<Node1>();
}
[Benchmark]
public object SimpleInjector()
{
return SimpleInjectorContainer.GetInstance<Node1>();
}
[Benchmark]
public object DryIoc()
{
return DryIocContainer.Resolve<Node1>();
}
[Benchmark(Baseline = true)]
public object GuInject()
{
return Kernel.Get<Node1>();
}
[Benchmark]
public object GuInjectBound()
{
return BoundKernel.Get<Node1>();
}
private sealed class Module : Ninject.Modules.NinjectModule
{
public override void Load()
{
this.Bind<Node1>().ToSelf().InSingletonScope();
this.Bind<Node2>().ToSelf().InSingletonScope();
this.Bind<Node3>().ToSelf().InSingletonScope();
this.Bind<Node4>().ToSelf().InSingletonScope();
this.Bind<Node5>().ToSelf().InSingletonScope();
this.Bind<Node6>().ToSelf().InSingletonScope();
this.Bind<Node7>().ToSelf().InSingletonScope();
this.Bind<Node8>().ToSelf().InSingletonScope();
this.Bind<Node9>().ToSelf().InSingletonScope();
this.Bind<Node10>().ToSelf().InSingletonScope();
this.Bind<Node11>().ToSelf().InSingletonScope();
this.Bind<Node12>().ToSelf().InSingletonScope();
this.Bind<Node13>().ToSelf().InSingletonScope();
this.Bind<Node14>().ToSelf().InSingletonScope();
this.Bind<Node15>().ToSelf().InSingletonScope();
this.Bind<Node16>().ToSelf().InSingletonScope();
this.Bind<Node17>().ToSelf().InSingletonScope();
this.Bind<Node18>().ToSelf().InSingletonScope();
this.Bind<Node19>().ToSelf().InSingletonScope();
this.Bind<Node20>().ToSelf().InSingletonScope();
this.Bind<Node21>().ToSelf().InSingletonScope();
this.Bind<Node22>().ToSelf().InSingletonScope();
this.Bind<Node23>().ToSelf().InSingletonScope();
this.Bind<Node24>().ToSelf().InSingletonScope();
this.Bind<Node25>().ToSelf().InSingletonScope();
this.Bind<Node26>().ToSelf().InSingletonScope();
this.Bind<Node27>().ToSelf().InSingletonScope();
this.Bind<Node28>().ToSelf().InSingletonScope();
this.Bind<Node29>().ToSelf().InSingletonScope();
this.Bind<Node30>().ToSelf().InSingletonScope();
this.Bind<Node31>().ToSelf().InSingletonScope();
this.Bind<Node32>().ToSelf().InSingletonScope();
this.Bind<Node33>().ToSelf().InSingletonScope();
this.Bind<Node34>().ToSelf().InSingletonScope();
this.Bind<Node35>().ToSelf().InSingletonScope();
this.Bind<Node36>().ToSelf().InSingletonScope();
this.Bind<Node37>().ToSelf().InSingletonScope();
this.Bind<Node38>().ToSelf().InSingletonScope();
this.Bind<Node39>().ToSelf().InSingletonScope();
this.Bind<Node40>().ToSelf().InSingletonScope();
this.Bind<Node41>().ToSelf().InSingletonScope();
this.Bind<Node42>().ToSelf().InSingletonScope();
this.Bind<Node43>().ToSelf().InSingletonScope();
this.Bind<Node44>().ToSelf().InSingletonScope();
this.Bind<Node45>().ToSelf().InSingletonScope();
this.Bind<Node46>().ToSelf().InSingletonScope();
this.Bind<Node47>().ToSelf().InSingletonScope();
this.Bind<Node48>().ToSelf().InSingletonScope();
this.Bind<Node49>().ToSelf().InSingletonScope();
}
}
}
}