Skip to content

Commit b0b0e0a

Browse files
committed
Added basic test to ensure all benchmarks/containers are working
1 parent f03e853 commit b0b0e0a

File tree

8 files changed

+316
-5
lines changed

8 files changed

+316
-5
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*.suo
33
*.user
44
/IocPerformance.userprefs
5-
/IocPerformance/bin
6-
/IocPerformance/obj
5+
bin
6+
obj
77
*.Cache
88
_ReSharper*
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{7C9F7453-18AB-41CB-83F9-CA3F52535898}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>IocPerformance.Test</RootNamespace>
11+
<AssemblyName>IocPerformance.Test</AssemblyName>
12+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="System" />
35+
<Reference Include="System.Core" />
36+
<Reference Include="System.Xml.Linq" />
37+
<Reference Include="System.Data.DataSetExtensions" />
38+
<Reference Include="Microsoft.CSharp" />
39+
<Reference Include="System.Data" />
40+
<Reference Include="System.Net.Http" />
41+
<Reference Include="System.Xml" />
42+
</ItemGroup>
43+
<ItemGroup>
44+
<Compile Include="SmokeTest.cs" />
45+
<Compile Include="Properties\AssemblyInfo.cs" />
46+
</ItemGroup>
47+
<ItemGroup>
48+
<PackageReference Include="xunit">
49+
<Version>2.4.1</Version>
50+
</PackageReference>
51+
<PackageReference Include="xunit.runner.visualstudio">
52+
<Version>2.4.1</Version>
53+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
54+
<PrivateAssets>all</PrivateAssets>
55+
</PackageReference>
56+
</ItemGroup>
57+
<ItemGroup>
58+
<ProjectReference Include="..\IocPerformance\IocPerformance.csproj">
59+
<Project>{c2cb4d53-6b69-4554-9da6-759a69c528c9}</Project>
60+
<Name>IocPerformance</Name>
61+
</ProjectReference>
62+
</ItemGroup>
63+
<ItemGroup>
64+
<None Include="app.config" />
65+
</ItemGroup>
66+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
67+
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("IocPerformance.Test")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("IocPerformance.Test")]
13+
[assembly: AssemblyCopyright("Copyright © 2019")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("7c9f7453-18ab-41cb-83f9-ca3f52535898")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

IocPerformance.Test/SmokeTest.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using IocPerformance.Adapters;
4+
using Xunit;
5+
6+
namespace IocPerformance.Test
7+
{
8+
public class SmokeTest
9+
{
10+
[Theory]
11+
[MemberData(nameof(Containers))]
12+
public void Warmup(IContainerAdapter container)
13+
{
14+
container.Prepare();
15+
16+
var benchmarks = BenchmarkFactory.CreateBenchmarks().ToArray();
17+
18+
// Run each benchmark before start measuring to ensure that all root services has been resolved.
19+
// Exclude the "Prepare" benchmarks as they dispose the container.
20+
foreach (var benchmark in benchmarks.Where(b => !b.Name.StartsWith("Prepare")))
21+
{
22+
if (benchmark.IsSupportedBy(container))
23+
{
24+
benchmark.Warmup(container);
25+
}
26+
}
27+
}
28+
29+
public static IEnumerable<object[]> Containers => ContainerAdapterFactory.CreateAdapters().Select(a => new object[] { a }).ToList();
30+
}
31+
}

IocPerformance.Test/app.config

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<configSections>
4+
<sectionGroup name="spring">
5+
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
6+
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
7+
</sectionGroup>
8+
<sectionGroup name="common">
9+
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
10+
</sectionGroup>
11+
</configSections>
12+
<spring>
13+
<context>
14+
<resource uri="config://spring/objects" />
15+
</context>
16+
<objects xmlns="http://www.springframework.net">
17+
<object id="loggingAdvice" type="IocPerformance.Interception.SpringInterceptionLogger" singleton="false" />
18+
<object name="IocPerformance.Classes.Dummy.IDummyOne" type="IocPerformance.Classes.Dummy.DummyOne, IocPerformance" singleton="false" />
19+
<object name="IocPerformance.Classes.Dummy.IDummyTwo" type="IocPerformance.Classes.Dummy.DummyTwo, IocPerformance" singleton="false" />
20+
<object name="IocPerformance.Classes.Dummy.IDummyThree" type="IocPerformance.Classes.Dummy.DummyThree, IocPerformance" singleton="false" />
21+
<object name="IocPerformance.Classes.Dummy.IDummyFour" type="IocPerformance.Classes.Dummy.DummyFour, IocPerformance" singleton="false" />
22+
<object name="IocPerformance.Classes.Dummy.IDummyFive" type="IocPerformance.Classes.Dummy.DummyFive, IocPerformance" singleton="false" />
23+
<object name="IocPerformance.Classes.Dummy.IDummySix" type="IocPerformance.Classes.Dummy.DummySix, IocPerformance" singleton="false" />
24+
<object name="IocPerformance.Classes.Dummy.IDummySeven" type="IocPerformance.Classes.Dummy.DummySeven, IocPerformance" singleton="false" />
25+
<object name="IocPerformance.Classes.Dummy.IDummyEight" type="IocPerformance.Classes.Dummy.DummyEight, IocPerformance" singleton="false" />
26+
<object name="IocPerformance.Classes.Dummy.IDummyNine" type="IocPerformance.Classes.Dummy.DummyNine, IocPerformance" singleton="false" />
27+
<object name="IocPerformance.Classes.Dummy.IDummyTen" type="IocPerformance.Classes.Dummy.DummyTen, IocPerformance" singleton="false" />
28+
<object name="IocPerformance.Classes.Standard.ISingleton1" type="IocPerformance.Classes.Standard.Singleton1, IocPerformance" singleton="true" />
29+
<object name="IocPerformance.Classes.Standard.ISingleton2" type="IocPerformance.Classes.Standard.Singleton2, IocPerformance" singleton="true" />
30+
<object name="IocPerformance.Classes.Standard.ISingleton3" type="IocPerformance.Classes.Standard.Singleton3, IocPerformance" singleton="true" />
31+
<object name="IocPerformance.Classes.Standard.ITransient1" type="IocPerformance.Classes.Standard.Transient1, IocPerformance" singleton="false" />
32+
<object name="IocPerformance.Classes.Standard.ITransient2" type="IocPerformance.Classes.Standard.Transient2, IocPerformance" singleton="false" />
33+
<object name="IocPerformance.Classes.Standard.ITransient3" type="IocPerformance.Classes.Standard.Transient3, IocPerformance" singleton="false" />
34+
<object name="IocPerformance.Classes.Standard.ICombined1" type="IocPerformance.Classes.Standard.Combined1, IocPerformance" singleton="false">
35+
<constructor-arg ref="IocPerformance.Classes.Standard.ISingleton1" />
36+
<constructor-arg ref="IocPerformance.Classes.Standard.ITransient1" />
37+
</object>
38+
<object name="IocPerformance.Classes.Standard.ICombined2" type="IocPerformance.Classes.Standard.Combined2, IocPerformance" singleton="false">
39+
<constructor-arg ref="IocPerformance.Classes.Standard.ISingleton2" />
40+
<constructor-arg ref="IocPerformance.Classes.Standard.ITransient2" />
41+
</object>
42+
<object name="IocPerformance.Classes.Standard.ICombined3" type="IocPerformance.Classes.Standard.Combined3, IocPerformance" singleton="false">
43+
<constructor-arg ref="IocPerformance.Classes.Standard.ISingleton3" />
44+
<constructor-arg ref="IocPerformance.Classes.Standard.ITransient3" />
45+
</object>
46+
<object id="calculatorTarget1" type="IocPerformance.Classes.Standard.Calculator1" singleton="false">
47+
</object>
48+
<object id="calculatorTarget2" type="IocPerformance.Classes.Standard.Calculator2" singleton="false">
49+
</object>
50+
<object id="calculatorTarget3" type="IocPerformance.Classes.Standard.Calculator3" singleton="false">
51+
</object>
52+
<object id="IocPerformance.Classes.Standard.ICalculator1" type="Spring.Aop.Framework.ProxyFactoryObject">
53+
<property name="targetName" value="calculatorTarget1">
54+
</property>
55+
<property name="isSingleton" value="false" />
56+
<property name="proxyInterfaces" value="IocPerformance.Classes.Standard.ICalculator1" />
57+
<property name="interceptorNames">
58+
<list>
59+
<value>loggingAdvice</value>
60+
</list>
61+
</property>
62+
</object>
63+
<object id="IocPerformance.Classes.Standard.ICalculator2" type="Spring.Aop.Framework.ProxyFactoryObject">
64+
<property name="targetName" value="calculatorTarget2">
65+
</property>
66+
<property name="isSingleton" value="false" />
67+
<property name="proxyInterfaces" value="IocPerformance.Classes.Standard.ICalculator2" />
68+
<property name="interceptorNames">
69+
<list>
70+
<value>loggingAdvice</value>
71+
</list>
72+
</property>
73+
</object>
74+
<object id="IocPerformance.Classes.Standard.ICalculator3" type="Spring.Aop.Framework.ProxyFactoryObject">
75+
<property name="targetName" value="calculatorTarget3">
76+
</property>
77+
<property name="isSingleton" value="false" />
78+
<property name="proxyInterfaces" value="IocPerformance.Classes.Standard.ICalculator3" />
79+
<property name="interceptorNames">
80+
<list>
81+
<value>loggingAdvice</value>
82+
</list>
83+
</property>
84+
</object>
85+
<object name="IocPerformance.Classes.Complex.IFirstService" type="IocPerformance.Classes.Complex.FirstService, IocPerformance" singleton="true" />
86+
<object name="IocPerformance.Classes.Complex.ISecondService" type="IocPerformance.Classes.Complex.SecondService, IocPerformance" singleton="true" />
87+
<object name="IocPerformance.Classes.Complex.IThirdService" type="IocPerformance.Classes.Complex.ThirdService, IocPerformance" singleton="true" />
88+
<object name="IocPerformance.Classes.Complex.ISubObjectOne" type="IocPerformance.Classes.Complex.SubObjectOne, IocPerformance" singleton="false">
89+
<constructor-arg ref="IocPerformance.Classes.Complex.IFirstService" />
90+
</object>
91+
<object name="IocPerformance.Classes.Complex.ISubObjectTwo" type="IocPerformance.Classes.Complex.SubObjectTwo, IocPerformance" singleton="false">
92+
<constructor-arg ref="IocPerformance.Classes.Complex.ISecondService" />
93+
</object>
94+
<object name="IocPerformance.Classes.Complex.ISubObjectThree" type="IocPerformance.Classes.Complex.SubObjectThree, IocPerformance" singleton="false">
95+
<constructor-arg ref="IocPerformance.Classes.Complex.IThirdService" />
96+
</object>
97+
<object name="IocPerformance.Classes.Complex.IComplex1" type="IocPerformance.Classes.Complex.Complex1, IocPerformance" singleton="false">
98+
<constructor-arg ref="IocPerformance.Classes.Complex.IFirstService" />
99+
<constructor-arg ref="IocPerformance.Classes.Complex.ISecondService" />
100+
<constructor-arg ref="IocPerformance.Classes.Complex.IThirdService" />
101+
<constructor-arg ref="IocPerformance.Classes.Complex.ISubObjectOne" />
102+
<constructor-arg ref="IocPerformance.Classes.Complex.ISubObjectTwo" />
103+
<constructor-arg ref="IocPerformance.Classes.Complex.ISubObjectThree" />
104+
</object>
105+
<object name="IocPerformance.Classes.Complex.IComplex2" type="IocPerformance.Classes.Complex.Complex2, IocPerformance" singleton="false">
106+
<constructor-arg ref="IocPerformance.Classes.Complex.IFirstService" />
107+
<constructor-arg ref="IocPerformance.Classes.Complex.ISecondService" />
108+
<constructor-arg ref="IocPerformance.Classes.Complex.IThirdService" />
109+
<constructor-arg ref="IocPerformance.Classes.Complex.ISubObjectOne" />
110+
<constructor-arg ref="IocPerformance.Classes.Complex.ISubObjectTwo" />
111+
<constructor-arg ref="IocPerformance.Classes.Complex.ISubObjectThree" />
112+
</object>
113+
<object name="IocPerformance.Classes.Complex.IComplex3" type="IocPerformance.Classes.Complex.Complex3, IocPerformance" singleton="false">
114+
<constructor-arg ref="IocPerformance.Classes.Complex.IFirstService" />
115+
<constructor-arg ref="IocPerformance.Classes.Complex.ISecondService" />
116+
<constructor-arg ref="IocPerformance.Classes.Complex.IThirdService" />
117+
<constructor-arg ref="IocPerformance.Classes.Complex.ISubObjectOne" />
118+
<constructor-arg ref="IocPerformance.Classes.Complex.ISubObjectTwo" />
119+
<constructor-arg ref="IocPerformance.Classes.Complex.ISubObjectThree" />
120+
</object>
121+
<object name="IocPerformance.Classes.Properties.IServiceA" type="IocPerformance.Classes.Properties.ServiceA, IocPerformance" singleton="true" />
122+
<object name="IocPerformance.Classes.Properties.IServiceB" type="IocPerformance.Classes.Properties.ServiceB, IocPerformance" singleton="true" />
123+
<object name="IocPerformance.Classes.Properties.IServiceC" type="IocPerformance.Classes.Properties.ServiceC, IocPerformance" singleton="true" />
124+
<object name="IocPerformance.Classes.Properties.ISubObjectA" type="IocPerformance.Classes.Properties.SubObjectA, IocPerformance" singleton="false">
125+
<property name="ServiceA" ref="IocPerformance.Classes.Properties.IServiceA" />
126+
</object>
127+
<object name="IocPerformance.Classes.Properties.ISubObjectB" type="IocPerformance.Classes.Properties.SubObjectB, IocPerformance" singleton="false">
128+
<property name="ServiceB" ref="IocPerformance.Classes.Properties.IServiceB" />
129+
</object>
130+
<object name="IocPerformance.Classes.Properties.ISubObjectC" type="IocPerformance.Classes.Properties.SubObjectC, IocPerformance" singleton="false">
131+
<property name="ServiceC" ref="IocPerformance.Classes.Properties.IServiceC" />
132+
</object>
133+
<object name="IocPerformance.Classes.Properties.IComplexPropertyObject1" type="IocPerformance.Classes.Properties.ComplexPropertyObject1, IocPerformance" singleton="false">
134+
<property name="ServiceA" ref="IocPerformance.Classes.Properties.IServiceA" />
135+
<property name="ServiceB" ref="IocPerformance.Classes.Properties.IServiceB" />
136+
<property name="ServiceC" ref="IocPerformance.Classes.Properties.IServiceC" />
137+
<property name="SubObjectA" ref="IocPerformance.Classes.Properties.ISubObjectA" />
138+
<property name="SubObjectB" ref="IocPerformance.Classes.Properties.ISubObjectB" />
139+
<property name="SubObjectC" ref="IocPerformance.Classes.Properties.ISubObjectC" />
140+
</object>
141+
<object name="IocPerformance.Classes.Properties.IComplexPropertyObject2" type="IocPerformance.Classes.Properties.ComplexPropertyObject2, IocPerformance" singleton="false">
142+
<property name="ServiceA" ref="IocPerformance.Classes.Properties.IServiceA" />
143+
<property name="ServiceB" ref="IocPerformance.Classes.Properties.IServiceB" />
144+
<property name="ServiceC" ref="IocPerformance.Classes.Properties.IServiceC" />
145+
<property name="SubObjectA" ref="IocPerformance.Classes.Properties.ISubObjectA" />
146+
<property name="SubObjectB" ref="IocPerformance.Classes.Properties.ISubObjectB" />
147+
<property name="SubObjectC" ref="IocPerformance.Classes.Properties.ISubObjectC" />
148+
</object>
149+
<object name="IocPerformance.Classes.Properties.IComplexPropertyObject3" type="IocPerformance.Classes.Properties.ComplexPropertyObject3, IocPerformance" singleton="false">
150+
<property name="ServiceA" ref="IocPerformance.Classes.Properties.IServiceA" />
151+
<property name="ServiceB" ref="IocPerformance.Classes.Properties.IServiceB" />
152+
<property name="ServiceC" ref="IocPerformance.Classes.Properties.IServiceC" />
153+
<property name="SubObjectA" ref="IocPerformance.Classes.Properties.ISubObjectA" />
154+
<property name="SubObjectB" ref="IocPerformance.Classes.Properties.ISubObjectB" />
155+
<property name="SubObjectC" ref="IocPerformance.Classes.Properties.ISubObjectC" />
156+
</object>
157+
</objects>
158+
</spring>
159+
<common>
160+
<logging></logging>
161+
</common>
162+
<startup>
163+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
164+
</startup>
165+
</configuration>

IocPerformance.sln

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26730.12
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29201.188
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IocPerformance", "IocPerformance\IocPerformance.csproj", "{C2CB4D53-6B69-4554-9DA6-759A69C528C9}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IocPerformance.Test", "IocPerformance.Test\IocPerformance.Test.csproj", "{7C9F7453-18AB-41CB-83F9-CA3F52535898}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
1517
{C2CB4D53-6B69-4554-9DA6-759A69C528C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{C2CB4D53-6B69-4554-9DA6-759A69C528C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{C2CB4D53-6B69-4554-9DA6-759A69C528C9}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{7C9F7453-18AB-41CB-83F9-CA3F52535898}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{7C9F7453-18AB-41CB-83F9-CA3F52535898}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{7C9F7453-18AB-41CB-83F9-CA3F52535898}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{7C9F7453-18AB-41CB-83F9-CA3F52535898}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE

IocPerformance/Adapters/ContainerAdapterBase.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ public abstract string Url
5757

5858
public abstract void PrepareBasic();
5959

60+
public override string ToString()
61+
{
62+
return this.Name;
63+
}
64+
6065
public virtual void Prepare()
6166
{
6267
this.PrepareBasic(); // by default any prepare should at least support basic one

0 commit comments

Comments
 (0)