This commit is contained in:
ENikS 2018-02-25 01:01:08 -05:00
Родитель 27eb84cc04
Коммит 7f685c5ea3
11 изменённых файлов: 70 добавлений и 26 удалений

Просмотреть файл

@ -15,6 +15,8 @@ namespace Benchmark.Abstractions
object Singleton();
object Resolve(Type type, string name);
object RegisterType(Type type, string name);
@ -43,6 +45,8 @@ namespace Benchmark.Abstractions
public abstract object Singleton();
public abstract object Resolve(Type type, string name);
public abstract object RegisterType(Type type, string name);
public abstract object RegisterTypeSingleton(Type type, string name);

@ -1 +1 @@
Subproject commit adf5e3fd7a74b09d54bc1736d700bd432bf2a8b2
Subproject commit 1a8e4088d96c7fb86d9bc6102cda1523dcc40185

@ -1 +1 @@
Subproject commit 3ac6db672da615ed606c42f3cc655bb747c2e524
Subproject commit 09c58fa925e43a14acb6b340ad15416aecfc3434

Просмотреть файл

@ -10,9 +10,9 @@ namespace Runner
static void Main(string[] args)
{
if (0 == args.Length)
BenchmarkSwitcher.FromAssembly(typeof(Program).GetTypeInfo().Assembly).RunAllJoined();
else
//if (0 == args.Length)
// BenchmarkSwitcher.FromAssembly(typeof(Program).GetTypeInfo().Assembly).RunAllJoined();
//else
BenchmarkSwitcher.FromAssembly(typeof(Program).GetTypeInfo().Assembly).Run(args);
}
}

Просмотреть файл

@ -8,7 +8,7 @@ namespace Runner.Setup
public BenchmarkConfiguration()
{
//Add(DefaultConfig.Instance); // *** add default loggers, reporters etc? ***
Add(Job.Default.WithUnrollFactor(1));
Add(Job.Default.WithUnrollFactor(1).WithInvocationCount(100000));
Set(new NameVersionOrderProvider());
}
}

Просмотреть файл

@ -7,7 +7,7 @@ namespace Runner.Tests
{
public class TestsBase
{
[Params("Unity.V4", "Unity.V5", "Unity.V6", "VS_MEF")]
[Params("Unity.V4", "Unity.V5", "Unity.V6")]
protected string Version;
protected ITestAdapter Adapter;
@ -26,7 +26,16 @@ namespace Runner.Tests
public virtual void SetupContainer()
{
Adapter.Container = Adapter.CreateContainer();
Adapter.RegisterType(typeof(Poco), null);
Adapter.RegisterTypeMapping(typeof(IService), typeof(Service), null);
Adapter.RegisterTypeMapping(typeof(IService), typeof(Service), "1");
Adapter.RegisterTypeMapping(typeof(IService), typeof(Service), "2");
}
}
public interface IService { }
public class Service : IService { }
public class Poco { }
}

Просмотреть файл

@ -1,19 +0,0 @@
using BenchmarkDotNet.Attributes;
using Runner.Setup;
namespace Runner.Tests
{
[BenchmarkCategory("Basic")]
[Config(typeof(BenchmarkConfiguration))]
public class Basic : TestsBase
{
[Benchmark(Description = "new Container()")]
public void NewUnityContainer() => Adapter.NewContainer();
[Benchmark(Description = "using(var uc = new Container()){}")]
public void UsingUnityContainer() => Adapter.UsingContainer();
[Benchmark(Description = "Container.Resolve<Container>()")]
public void Singleton() => Adapter.Singleton();
}
}

35
Runner/Tests/ColdStart.cs Normal file
Просмотреть файл

@ -0,0 +1,35 @@
using BenchmarkDotNet.Attributes;
using Runner.Setup;
using System.Collections.Generic;
namespace Runner.Tests
{
[BenchmarkCategory("Basic")]
[Config(typeof(BenchmarkConfiguration))]
public class ColdStart : TestsBase
{
//[Benchmark(Description = "new Container()")]
//public void NewUnityContainer() => Adapter.NewContainer();
//[Benchmark(Description = "using(var uc = new Container()){}")]
//public void UsingUnityContainer() => Adapter.UsingContainer();
[Benchmark]
public void Singleton() => Adapter.Singleton();
[Benchmark]
public void Unregistered() => Adapter.Resolve(typeof(object), null);
[Benchmark]
public void Transient() => Adapter.Resolve(typeof(Poco), null);
[Benchmark]
public void Mapping() => Adapter.Resolve(typeof(IService), null);
[Benchmark]
public void Array() => Adapter.Resolve(typeof(IService[]), null);
[Benchmark]
public void Enumerable() => Adapter.Resolve(typeof(IEnumerable<IService>), null);
}
}

Просмотреть файл

@ -16,6 +16,11 @@ namespace Unity.V4.Adapter
return ((UnityContainer)Container).Resolve(typeof(IUnityContainer), null, new ResolverOverride[0]) ;
}
public override object Resolve(Type type, string name)
{
return ((UnityContainer)Container).Resolve(type, name, new ResolverOverride[0]);
}
public override object RegisterType(Type type, string name)
{
return ((UnityContainer)Container).RegisterType(null, type, name, null, new InjectionMember[0]);

Просмотреть файл

@ -18,6 +18,11 @@ namespace Unity.V5.Adapter
return ((UnityContainer)Container).Resolve(typeof(IUnityContainer), null, new ResolverOverride[0]);
}
public override object Resolve(Type type, string name)
{
return ((UnityContainer)Container).Resolve(type, name, new ResolverOverride[0]);
}
public override object RegisterType(Type type, string name)
{
return ((UnityContainer)Container).RegisterType(null, type, name, null, new InjectionMember[0]);

Просмотреть файл

@ -17,6 +17,11 @@ namespace Unity.V6.Adapter
return ((UnityContainer)Container).Resolve(typeof(IUnityContainer), null, null);
}
public override object Resolve(Type type, string name)
{
return ((UnityContainer)Container).Resolve(type, name);
}
public override object RegisterType(Type type, string name)
{
return ((UnityContainer)Container).RegisterType(null, type, name, null, new InjectionMember[0]);