Files
Umbraco-CMS/src/Umbraco.Tests.Benchmarks/TypeFinderBenchmarks.cs

31 lines
1.1 KiB
C#
Raw Normal View History

using System.Linq;
using BenchmarkDotNet.Attributes;
using Microsoft.Extensions.Logging.Abstractions;
using Umbraco.Cms.Core.Composing;
using Umbraco.Extensions;
2020-03-11 15:28:08 +11:00
namespace Umbraco.Tests.Benchmarks
{
[MediumRunJob]
[MemoryDiagnoser]
public class TypeFinderBenchmarks
{
[Benchmark(Baseline = true)]
public void WithGetReferencingAssembliesCheck()
{
var typeFinder1 = new TypeFinder(new NullLogger<TypeFinder>(), new DefaultUmbracoAssemblyProvider(GetType().Assembly, NullLoggerFactory.Instance), new VaryingRuntimeHash());
2020-03-11 15:28:08 +11:00
var found = typeFinder1.FindClassesOfType<IDiscoverable>().Count();
}
[Benchmark]
public void WithoutGetReferencingAssembliesCheck()
{
var typeFinder2 = new TypeFinder(new NullLogger<TypeFinder>(), new DefaultUmbracoAssemblyProvider(GetType().Assembly, NullLoggerFactory.Instance), new VaryingRuntimeHash());
2020-03-11 15:28:08 +11:00
typeFinder2.QueryWithReferencingAssemblies = false;
var found = typeFinder2.FindClassesOfType<IDiscoverable>().Count();
}
2020-03-11 15:28:08 +11:00
}
}