Update Metrics Benchmarks (#2418)
* Add benchmarks for TagList * Update the benchmark results in the comments Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
This commit is contained in:
parent
2aa22696c9
commit
7b26a647a3
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Metrics;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using OpenTelemetry;
|
||||
|
|
@ -23,26 +24,36 @@ using OpenTelemetry.Metrics;
|
|||
|
||||
/*
|
||||
BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19043
|
||||
Intel Core i7-8650U CPU 1.90GHz (Kaby Lake R), 1 CPU, 8 logical and 4 physical cores
|
||||
.NET Core SDK=5.0.302
|
||||
[Host] : .NET Core 3.1.17 (CoreCLR 4.700.21.31506, CoreFX 4.700.21.31502), X64 RyuJIT
|
||||
DefaultJob : .NET Core 3.1.17 (CoreCLR 4.700.21.31506, CoreFX 4.700.21.31502), X64 RyuJIT
|
||||
Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores
|
||||
.NET Core SDK=6.0.100-rc.1.21458.32
|
||||
[Host] : .NET Core 3.1.19 (CoreCLR 4.700.21.41101, CoreFX 4.700.21.41603), X64 RyuJIT
|
||||
DefaultJob : .NET Core 3.1.19 (CoreCLR 4.700.21.41101, CoreFX 4.700.21.41603), X64 RyuJIT
|
||||
|
||||
|
||||
| Method | WithSDK | Mean | Error | StdDev | Median | Gen 0 | Gen 1 | Gen 2 | Allocated |
|
||||
|-------------------------- |-------- |------------:|----------:|----------:|------------:|-------:|------:|------:|----------:|
|
||||
| CounterHotPath | False | 21.16 ns | 1.807 ns | 5.037 ns | 19.55 ns | - | - | - | - |
|
||||
| CounterWith1LabelsHotPath | False | 32.33 ns | 1.596 ns | 4.501 ns | 30.53 ns | - | - | - | - |
|
||||
| CounterWith3LabelsHotPath | False | 88.70 ns | 3.963 ns | 11.497 ns | 86.24 ns | - | - | - | - |
|
||||
| CounterWith5LabelsHotPath | False | 122.19 ns | 4.101 ns | 11.898 ns | 120.32 ns | 0.0248 | - | - | 104 B |
|
||||
| CounterWith6LabelsHotPath | False | 151.19 ns | 5.875 ns | 17.324 ns | 146.80 ns | 0.0286 | - | - | 120 B |
|
||||
| CounterWith7LabelsHotPath | False | 170.32 ns | 4.907 ns | 14.392 ns | 165.91 ns | 0.0324 | - | - | 136 B |
|
||||
| CounterHotPath | True | 52.47 ns | 1.080 ns | 2.481 ns | 51.89 ns | - | - | - | - |
|
||||
| CounterWith1LabelsHotPath | True | 142.46 ns | 2.118 ns | 1.769 ns | 142.51 ns | - | - | - | - |
|
||||
| CounterWith3LabelsHotPath | True | 594.14 ns | 11.827 ns | 21.326 ns | 591.94 ns | - | - | - | - |
|
||||
| CounterWith5LabelsHotPath | True | 843.52 ns | 16.612 ns | 17.775 ns | 835.77 ns | 0.0553 | - | - | 232 B |
|
||||
| CounterWith6LabelsHotPath | True | 957.71 ns | 18.017 ns | 19.278 ns | 953.99 ns | 0.0629 | - | - | 264 B |
|
||||
| CounterWith7LabelsHotPath | True | 1,112.38 ns | 21.805 ns | 27.576 ns | 1,104.74 ns | 0.0706 | - | - | 296 B |
|
||||
| Method | WithSDK | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|
||||
|-------------------------------------- |-------- |----------:|---------:|---------:|-------:|------:|------:|----------:|
|
||||
| CounterHotPath | False | 12.87 ns | 0.086 ns | 0.080 ns | - | - | - | - |
|
||||
| CounterWith1LabelsHotPath | False | 19.36 ns | 0.083 ns | 0.069 ns | - | - | - | - |
|
||||
| CounterWith3LabelsHotPath | False | 53.71 ns | 0.336 ns | 0.314 ns | - | - | - | - |
|
||||
| CounterWith5LabelsHotPath | False | 79.82 ns | 0.525 ns | 0.439 ns | 0.0166 | - | - | 104 B |
|
||||
| CounterWith6LabelsHotPath | False | 91.35 ns | 0.827 ns | 0.733 ns | 0.0191 | - | - | 120 B |
|
||||
| CounterWith7LabelsHotPath | False | 104.40 ns | 0.924 ns | 0.865 ns | 0.0216 | - | - | 136 B |
|
||||
| CounterWith1LabelsHotPathUsingTagList | False | 50.43 ns | 0.415 ns | 0.388 ns | - | - | - | - |
|
||||
| CounterWith3LabelsHotPathUsingTagList | False | 88.48 ns | 0.402 ns | 0.376 ns | - | - | - | - |
|
||||
| CounterWith5LabelsHotPathUsingTagList | False | 121.61 ns | 0.472 ns | 0.418 ns | - | - | - | - |
|
||||
| CounterWith6LabelsHotPathUsingTagList | False | 139.11 ns | 0.593 ns | 0.554 ns | - | - | - | - |
|
||||
| CounterWith7LabelsHotPathUsingTagList | False | 154.07 ns | 0.773 ns | 0.685 ns | - | - | - | - |
|
||||
| CounterHotPath | True | 38.23 ns | 0.235 ns | 0.220 ns | - | - | - | - |
|
||||
| CounterWith1LabelsHotPath | True | 102.48 ns | 0.942 ns | 0.881 ns | - | - | - | - |
|
||||
| CounterWith3LabelsHotPath | True | 417.00 ns | 2.904 ns | 2.716 ns | - | - | - | - |
|
||||
| CounterWith5LabelsHotPath | True | 578.45 ns | 5.287 ns | 4.946 ns | 0.0162 | - | - | 104 B |
|
||||
| CounterWith6LabelsHotPath | True | 665.56 ns | 3.716 ns | 3.476 ns | 0.0191 | - | - | 120 B |
|
||||
| CounterWith7LabelsHotPath | True | 778.88 ns | 5.482 ns | 4.578 ns | 0.0210 | - | - | 136 B |
|
||||
| CounterWith1LabelsHotPathUsingTagList | True | 135.55 ns | 1.012 ns | 0.947 ns | - | - | - | - |
|
||||
| CounterWith3LabelsHotPathUsingTagList | True | 457.96 ns | 4.242 ns | 3.968 ns | - | - | - | - |
|
||||
| CounterWith5LabelsHotPathUsingTagList | True | 631.81 ns | 3.423 ns | 2.858 ns | - | - | - | - |
|
||||
| CounterWith6LabelsHotPathUsingTagList | True | 719.81 ns | 4.704 ns | 4.400 ns | - | - | - | - |
|
||||
| CounterWith7LabelsHotPathUsingTagList | True | 828.88 ns | 4.321 ns | 3.830 ns | - | - | - | - |
|
||||
*/
|
||||
|
||||
namespace Benchmarks.Metrics
|
||||
|
|
@ -137,5 +148,72 @@ namespace Benchmarks.Metrics
|
|||
var tag7 = new KeyValuePair<string, object>("DimName7", this.dimensionValues[this.random.Next(0, 1)]);
|
||||
this.counter?.Add(100, tag1, tag2, tag3, tag4, tag5, tag6, tag7);
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public void CounterWith1LabelsHotPathUsingTagList()
|
||||
{
|
||||
var tags = new TagList
|
||||
{
|
||||
{ "DimName1", this.dimensionValues[this.random.Next(0, 2)] },
|
||||
};
|
||||
this.counter?.Add(100, tags);
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public void CounterWith3LabelsHotPathUsingTagList()
|
||||
{
|
||||
var tags = new TagList
|
||||
{
|
||||
{ "DimName1", this.dimensionValues[this.random.Next(0, 10)] },
|
||||
{ "DimName2", this.dimensionValues[this.random.Next(0, 10)] },
|
||||
{ "DimName3", this.dimensionValues[this.random.Next(0, 10)] },
|
||||
};
|
||||
this.counter?.Add(100, tags);
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public void CounterWith5LabelsHotPathUsingTagList()
|
||||
{
|
||||
var tags = new TagList
|
||||
{
|
||||
{ "DimName1", this.dimensionValues[this.random.Next(0, 2)] },
|
||||
{ "DimName2", this.dimensionValues[this.random.Next(0, 2)] },
|
||||
{ "DimName3", this.dimensionValues[this.random.Next(0, 5)] },
|
||||
{ "DimName4", this.dimensionValues[this.random.Next(0, 5)] },
|
||||
{ "DimName5", this.dimensionValues[this.random.Next(0, 10)] },
|
||||
};
|
||||
this.counter?.Add(100, tags);
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public void CounterWith6LabelsHotPathUsingTagList()
|
||||
{
|
||||
var tags = new TagList
|
||||
{
|
||||
{ "DimName1", this.dimensionValues[this.random.Next(0, 2)] },
|
||||
{ "DimName2", this.dimensionValues[this.random.Next(0, 2)] },
|
||||
{ "DimName3", this.dimensionValues[this.random.Next(0, 5)] },
|
||||
{ "DimName4", this.dimensionValues[this.random.Next(0, 5)] },
|
||||
{ "DimName5", this.dimensionValues[this.random.Next(0, 5)] },
|
||||
{ "DimName6", this.dimensionValues[this.random.Next(0, 2)] },
|
||||
};
|
||||
this.counter?.Add(100, tags);
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public void CounterWith7LabelsHotPathUsingTagList()
|
||||
{
|
||||
var tags = new TagList
|
||||
{
|
||||
{ "DimName1", this.dimensionValues[this.random.Next(0, 2)] },
|
||||
{ "DimName2", this.dimensionValues[this.random.Next(0, 2)] },
|
||||
{ "DimName3", this.dimensionValues[this.random.Next(0, 5)] },
|
||||
{ "DimName4", this.dimensionValues[this.random.Next(0, 5)] },
|
||||
{ "DimName5", this.dimensionValues[this.random.Next(0, 5)] },
|
||||
{ "DimName6", this.dimensionValues[this.random.Next(0, 2)] },
|
||||
{ "DimName7", this.dimensionValues[this.random.Next(0, 1)] },
|
||||
};
|
||||
this.counter?.Add(100, tags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue