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

39 lines
1.2 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
2020-03-11 15:28:08 +11:00
{
private readonly TypeFinder _typeFinder1;
private readonly TypeFinder _typeFinder2;
public TypeFinderBenchmarks()
2020-03-11 15:28:08 +11:00
{
_typeFinder1 = new TypeFinder(new NullLogger<TypeFinder>(), new DefaultUmbracoAssemblyProvider(GetType().Assembly, NullLoggerFactory.Instance), null);
_typeFinder2 = new TypeFinder(new NullLogger<TypeFinder>(), new DefaultUmbracoAssemblyProvider(GetType().Assembly, NullLoggerFactory.Instance), null)
{
QueryWithReferencingAssemblies = false
};
}
2020-03-11 15:28:08 +11:00
// TODO: This setting seems to make no difference anymore
2020-03-11 15:28:08 +11:00
[Benchmark(Baseline = true)]
public void WithGetReferencingAssembliesCheck()
{
var found = _typeFinder1.FindClassesOfType<IDiscoverable>().Count();
}
[Benchmark]
public void WithoutGetReferencingAssembliesCheck()
{
var found = _typeFinder2.FindClassesOfType<IDiscoverable>().Count();
2020-03-11 15:28:08 +11:00
}
}