* Obsoletions related to Delivery API * Fix TypeLoader and TypeFinder tests * Remove obsolete and default implementations of IFileSource and IFileTypeCollection * More Delivery API related obsoletions * VariationContextAccessor related * ValueFactories obsoletion and fix references * ValueSetBuilders obsoletions * ValueConverters obsoletions * Other obsolete ctors and methods * Forgotten VariationContextAccessor obsoletion * More obsoletions * XPath related obsoletions * Revert XmlHelper changes * Delete RenamedRootNavigator and its tests * Fix test * XmlHelper obsoletion * Return null instead of GetXPathValue * Obsolete entire class instead * Remove XPath obsoletions from IPublishedCache * Remove XPath-related if-block that is no longer needed * Change obsolete msg for classes needed for NuCache * Moving classes to NuCache and making them internal * Remove more XPath-related obsoletions * Remove NavigableNavigator and its tests * Cleanup * Remove Xpath references from tests * Revert interface deletion in MediaCache * Using XOR operation Co-authored-by: Nuklon <Nuklon@users.noreply.github.com> --------- Co-authored-by: Nuklon <Nuklon@users.noreply.github.com>
72 lines
2.0 KiB
C#
72 lines
2.0 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BenchmarkDotNet.Attributes;
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
using Umbraco.Cms.Core.Composing;
|
|
|
|
namespace Umbraco.Tests.Benchmarks;
|
|
|
|
[MediumRunJob]
|
|
[MemoryDiagnoser]
|
|
public class TypeLoaderBenchmarks
|
|
{
|
|
private readonly TypeLoader _typeLoader1;
|
|
private readonly TypeLoader _typeLoader2;
|
|
|
|
public TypeLoaderBenchmarks()
|
|
{
|
|
var typeFinder1 = new TypeFinder(
|
|
new NullLogger<TypeFinder>(),
|
|
new DefaultUmbracoAssemblyProvider(GetType().Assembly, NullLoggerFactory.Instance),
|
|
null);
|
|
|
|
_typeLoader1 = new TypeLoader(typeFinder1, NullLogger<TypeLoader>.Instance);
|
|
_typeLoader2 = new TypeLoader(typeFinder1, NullLogger<TypeLoader>.Instance);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Use a predefined cache of types (names) - this is an example of what is saved to disk and loaded on startup
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private Dictionary<(string, string), IEnumerable<string>> GetCache()
|
|
=> new()
|
|
{
|
|
[(typeof(ITypeLoaderBenchmarkPlugin).FullName, null)] = new List<string>
|
|
{
|
|
typeof(CustomAssemblyProvider1).FullName,
|
|
typeof(CustomAssemblyProvider2).FullName,
|
|
typeof(CustomAssemblyProvider3).FullName
|
|
}
|
|
};
|
|
|
|
[Benchmark(Baseline = true)]
|
|
public void WithTypesCache()
|
|
{
|
|
var found = _typeLoader1.GetTypes<ITypeLoaderBenchmarkPlugin>().Count();
|
|
}
|
|
|
|
[Benchmark]
|
|
public void WithoutTypesCache()
|
|
{
|
|
var found = _typeLoader2.GetTypes<ITypeLoaderBenchmarkPlugin>(false).Count();
|
|
}
|
|
}
|
|
|
|
// These are the types we'll find for the benchmark
|
|
|
|
public interface ITypeLoaderBenchmarkPlugin
|
|
{
|
|
}
|
|
|
|
public class CustomAssemblyProvider1 : ITypeLoaderBenchmarkPlugin
|
|
{
|
|
}
|
|
|
|
public class CustomAssemblyProvider2 : ITypeLoaderBenchmarkPlugin
|
|
{
|
|
}
|
|
|
|
public class CustomAssemblyProvider3 : ITypeLoaderBenchmarkPlugin
|
|
{
|
|
}
|