2021-02-22 11:22:49 +13:00
|
|
|
using System;
|
2022-06-21 08:09:38 +02:00
|
|
|
using BenchmarkDotNet.Attributes;
|
2021-02-22 11:22:49 +13:00
|
|
|
using Umbraco.Tests.Benchmarks.Config;
|
|
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
namespace Umbraco.Tests.Benchmarks;
|
|
|
|
|
|
|
|
|
|
[QuickRunWithMemoryDiagnoserConfig]
|
|
|
|
|
public class LoggerAllocationBenchmark
|
2021-02-22 11:22:49 +13:00
|
|
|
{
|
2022-06-21 08:09:38 +02:00
|
|
|
private readonly string rawQuery = "";
|
|
|
|
|
private readonly int totalItemCount;
|
|
|
|
|
|
|
|
|
|
[Benchmark(Baseline = true)]
|
|
|
|
|
public void Baseline()
|
2021-02-22 11:22:49 +13:00
|
|
|
{
|
2022-06-21 08:09:38 +02:00
|
|
|
for (var i = 0; i < 1000; i++)
|
2021-02-22 11:22:49 +13:00
|
|
|
{
|
2022-06-21 08:09:38 +02:00
|
|
|
OriginalDebugSignature(GetType(), "DeleteFromIndex with query: {Query} (found {TotalItems} results)",
|
|
|
|
|
rawQuery, totalItemCount);
|
2021-02-22 11:22:49 +13:00
|
|
|
}
|
2022-06-21 08:09:38 +02:00
|
|
|
}
|
2021-02-22 11:22:49 +13:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
[Benchmark]
|
|
|
|
|
public void NewOverload2()
|
|
|
|
|
{
|
|
|
|
|
for (var i = 0; i < 1000; i++)
|
2021-02-22 11:22:49 +13:00
|
|
|
{
|
2022-06-21 08:09:38 +02:00
|
|
|
NewDebugSignature(GetType(), "DeleteFromIndex with query: {Query} (found {TotalItems} results)", rawQuery,
|
|
|
|
|
totalItemCount);
|
2021-02-22 11:22:49 +13:00
|
|
|
}
|
2022-06-21 08:09:38 +02:00
|
|
|
}
|
2021-02-22 11:22:49 +13:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public void OriginalDebugSignature(Type reporting, string messageTemplate, params object[] propertyValues)
|
|
|
|
|
{
|
|
|
|
|
}
|
2021-02-22 11:22:49 +13:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public void NewDebugSignature<T1, T2>(Type reporting, string messageTemplate, T1 param1, T2 param2)
|
|
|
|
|
{
|
|
|
|
|
}
|
2021-02-22 11:22:49 +13:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
// BenchmarkDotNet=v0.11.3, OS=Windows 10.0.18362
|
|
|
|
|
//Intel Core i5-8265U CPU 1.60GHz(Kaby Lake R), 1 CPU, 8 logical and 4 physical cores
|
|
|
|
|
// [Host] : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 32bit LegacyJIT-v4.8.4180.0
|
|
|
|
|
// Job-JIATTD : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 32bit LegacyJIT-v4.8.4180.0
|
2021-02-22 11:22:49 +13:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
//IterationCount=3 IterationTime=100.0000 ms LaunchCount = 1
|
|
|
|
|
//WarmupCount=3
|
2021-02-22 11:22:49 +13:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
// Method | Mean | Error | StdDev | Ratio | Gen 0/1k Op | Gen 1/1k Op | Gen 2/1k Op | Allocated Memory/Op |
|
|
|
|
|
//------------- |----------:|----------:|----------:|------:|------------:|------------:|------------:|--------------------:|
|
|
|
|
|
// Baseline | 14.599 us | 1.0882 us | 0.0596 us | 1.00 | 10.0420 | - | - | 32048 B |
|
|
|
|
|
// NewOverload2 | 1.775 us | 0.4056 us | 0.0222 us | 0.12 | - | - | - | - |
|
2021-02-22 11:22:49 +13:00
|
|
|
}
|