Merge branch temp8 into temp8-di2690

This commit is contained in:
Stephan
2018-12-18 15:42:45 +01:00
136 changed files with 3339 additions and 3147 deletions

View File

@@ -11,7 +11,13 @@ using Umbraco.Core;
namespace Umbraco.Tests.Benchmarks
{
[Config(typeof(Config))]
// some conclusions
// - ActivatorCreateInstance is slow
// - it's faster to get+invoke the ctor
// - emitting the ctor is unless if invoked only 1
//[Config(typeof(Config))]
[MemoryDiagnoser]
public class CtorInvokeBenchmarks
{
private class Config : ManualConfig
@@ -158,6 +164,28 @@ namespace Umbraco.Tests.Benchmarks
var foo = new Foo(_foo);
}
[Benchmark]
public void EmitCtor()
{
var ctor = ReflectionUtilities.EmitConstuctor<Func<IFoo, Foo>>();
var foo = ctor(_foo);
}
[Benchmark]
public void ActivatorCreateInstance()
{
var foo = Activator.CreateInstance(typeof(Foo), _foo);
}
[Benchmark]
public void GetAndInvokeCtor()
{
var ctorArgTypes = new[] { typeof(IFoo) };
var type = typeof(Foo);
var ctorInfo = type.GetConstructor(ctorArgTypes);
var foo = ctorInfo.Invoke(new object[] { _foo });
}
[Benchmark]
public void InvokeCtor()
{

View File

@@ -90,7 +90,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet">
<Version>0.11.2</Version>
<Version>0.11.3</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />