2021-06-01 05:13:45 +10:00
|
|
|
using System.Linq;
|
2021-02-18 11:06:02 +01:00
|
|
|
using BenchmarkDotNet.Attributes;
|
2020-09-16 13:08:27 +02:00
|
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.Composing;
|
|
|
|
|
using Umbraco.Extensions;
|
2020-03-11 15:28:08 +11:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
namespace Umbraco.Tests.Benchmarks;
|
|
|
|
|
|
|
|
|
|
[MediumRunJob]
|
|
|
|
|
[MemoryDiagnoser]
|
|
|
|
|
public class TypeFinderBenchmarks
|
2020-03-11 15:28:08 +11:00
|
|
|
{
|
2022-06-21 08:09:38 +02:00
|
|
|
private readonly TypeFinder _typeFinder1;
|
|
|
|
|
private readonly TypeFinder _typeFinder2;
|
2021-06-01 05:13:45 +10:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public TypeFinderBenchmarks()
|
2020-03-11 15:28:08 +11:00
|
|
|
{
|
2024-04-09 09:06:48 +02: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)
|
2021-06-01 05:13:45 +10:00
|
|
|
{
|
|
|
|
|
QueryWithReferencingAssemblies = false
|
|
|
|
|
};
|
2022-06-21 08:09:38 +02:00
|
|
|
}
|
2020-03-11 15:28:08 +11:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
// TODO: This setting seems to make no difference anymore
|
2020-03-11 15:28:08 +11:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
[Benchmark(Baseline = true)]
|
|
|
|
|
public void WithGetReferencingAssembliesCheck()
|
|
|
|
|
{
|
|
|
|
|
var found = _typeFinder1.FindClassesOfType<IDiscoverable>().Count();
|
|
|
|
|
}
|
2020-04-03 01:08:52 +11:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
[Benchmark]
|
|
|
|
|
public void WithoutGetReferencingAssembliesCheck()
|
|
|
|
|
{
|
|
|
|
|
var found = _typeFinder2.FindClassesOfType<IDiscoverable>().Count();
|
2020-03-11 15:28:08 +11:00
|
|
|
}
|
|
|
|
|
}
|