Adding local benchmarks
This commit is contained in:
Родитель
7292e2102e
Коммит
fe8638de09
|
@ -28,9 +28,4 @@
|
|||
<ProjectReference Include="..\src\Unity.Container.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Container\" />
|
||||
<Folder Include="Extensions\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
using BenchmarkDotNet.Running;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Running;
|
||||
using System.Reflection;
|
||||
using Unity.Container.Tests;
|
||||
|
||||
namespace Unity.Benchmark
|
||||
|
@ -7,11 +10,16 @@ namespace Unity.Benchmark
|
|||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
BenchmarkSwitcher.FromAssemblies(new[]
|
||||
BenchmarkSwitcher.FromAssemblies(new[]
|
||||
{
|
||||
typeof(Program).Assembly,
|
||||
typeof(PatternTestMethodAttribute).Assembly,
|
||||
}).Run(args);
|
||||
Assembly.GetExecutingAssembly()
|
||||
}).Run(args, GetGlobalConfig());
|
||||
}
|
||||
|
||||
static IConfig GetGlobalConfig()
|
||||
=> DefaultConfig.Instance
|
||||
.AddJob(Job.Default.AsDefault())
|
||||
.WithOptions(ConfigOptions.DisableOptimizationsValidator);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Unity.Storage;
|
||||
|
||||
namespace Container.Scope
|
||||
|
@ -6,14 +7,7 @@ namespace Container.Scope
|
|||
// [TestClass]
|
||||
public class HAMTScopeTests : ScopeTests
|
||||
{
|
||||
#region Scaffolding
|
||||
|
||||
[ClassInitialize]
|
||||
public static new void InitializeClass(TestContext context)
|
||||
=> ScopeTests.InitializeClass(context);
|
||||
|
||||
#endregion
|
||||
|
||||
[IterationSetup]
|
||||
[TestInitialize]
|
||||
public virtual void InitializeTest() => Scope = new HAMTScope(1);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Unity.Storage;
|
||||
|
||||
namespace Container.Scope
|
||||
|
@ -8,12 +9,9 @@ namespace Container.Scope
|
|||
{
|
||||
#region Scaffolding
|
||||
|
||||
[ClassInitialize]
|
||||
public static new void InitializeClass(TestContext context)
|
||||
=> ScopeTests.InitializeClass(context);
|
||||
|
||||
#endregion
|
||||
|
||||
[IterationSetup]
|
||||
[TestInitialize]
|
||||
public virtual void InitializeTest() => Scope = new HashScope(1);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Unity.Lifetime;
|
||||
|
||||
namespace Container.Scope
|
||||
|
@ -44,6 +45,7 @@ namespace Container.Scope
|
|||
Assert.AreEqual(2, Scope.ToArray().Length);
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
[TestMethod, TestProperty(TESTING_IUC, TRAIT_ADD)]
|
||||
public void RegisterTypeWithName()
|
||||
{
|
||||
|
@ -53,7 +55,6 @@ namespace Container.Scope
|
|||
// Validate
|
||||
Assert.AreEqual(1, Scope.Version);
|
||||
Assert.AreEqual(2, Scope.Count);
|
||||
Assert.AreEqual(2, Scope.ToArray().Length);
|
||||
}
|
||||
|
||||
[TestMethod, TestProperty(TESTING_IUC, TRAIT_ADD)]
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Unity;
|
||||
|
@ -24,8 +26,15 @@ namespace Container.Scope
|
|||
|
||||
#region Fields
|
||||
|
||||
protected static Type[] TestTypes;
|
||||
protected static string[] TestNames;
|
||||
protected static IEnumerable<TypeInfo> DefinedTypes = Assembly.GetAssembly(typeof(int)).DefinedTypes;
|
||||
protected static string[] TestNames = Enumerable.Repeat<string>(null, 4)
|
||||
.Concat(DefinedTypes.Select(t => t.Name).Take(5))
|
||||
.Concat(DefinedTypes.Select(t => t.Name).Distinct().Take(100))
|
||||
.ToArray();
|
||||
protected static Type[] TestTypes = DefinedTypes.Where(t => t != typeof(IServiceProvider))
|
||||
.Take(2000)
|
||||
.ToArray();
|
||||
|
||||
protected static LifetimeManager Manager = new ContainerControlledLifetimeManager
|
||||
{
|
||||
Data = "Zero",
|
||||
|
@ -35,24 +44,6 @@ namespace Container.Scope
|
|||
protected Unity.Storage.Scope Scope;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Scaffolding
|
||||
|
||||
[ClassInitialize]
|
||||
public static void InitializeClass(TestContext _)
|
||||
{
|
||||
var DefinedTypes = Assembly.GetAssembly(typeof(int)).DefinedTypes;
|
||||
TestNames = Enumerable.Repeat<string>(null, 4)
|
||||
.Concat(DefinedTypes.Select(t => t.Name).Take(5))
|
||||
.Concat(DefinedTypes.Select(t => t.Name).Distinct().Take(100))
|
||||
.ToArray();
|
||||
TestTypes = DefinedTypes.Where(t => t != typeof(IServiceProvider))
|
||||
.Take(2000)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public static class ScopeTestExtensions
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<TargetFramework Condition=" '$(TargetFramework)' == '' ">net6.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
|
Загрузка…
Ссылка в новой задаче