|
19 | 19 | using OpenTelemetry;
|
20 | 20 | using OpenTelemetry.Logs;
|
21 | 21 |
|
| 22 | +/* |
| 23 | +// * Summary * |
| 24 | +
|
| 25 | +BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19044.1466 (21H2) |
| 26 | +Intel Core i7-4790 CPU 3.60GHz (Haswell), 1 CPU, 8 logical and 4 physical cores |
| 27 | +.NET SDK=6.0.101 |
| 28 | + [Host] : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT |
| 29 | + DefaultJob : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT |
| 30 | +
|
| 31 | +
|
| 32 | +| Method | Mean | Error | StdDev | Gen 0 | Allocated | |
| 33 | +|--------------------------------------- |-----------:|----------:|----------:|-------:|----------:| |
| 34 | +| NoListener | 72.365 ns | 0.9425 ns | 0.8817 ns | 0.0153 | 64 B | |
| 35 | +| NoListenerWithLoggerMessageGenerator | 4.769 ns | 0.0161 ns | 0.0142 ns | - | - | |
| 36 | +| OneProcessor | 168.330 ns | 0.6198 ns | 0.5494 ns | 0.0553 | 232 B | |
| 37 | +| OneProcessorWithLoggerMessageGenerator | 142.898 ns | 0.5233 ns | 0.4086 ns | 0.0401 | 168 B | |
| 38 | +| TwoProcessors | 173.727 ns | 0.5978 ns | 0.4992 ns | 0.0553 | 232 B | |
| 39 | +| ThreeProcessors | 174.295 ns | 0.7697 ns | 0.7200 ns | 0.0553 | 232 B | |
| 40 | +*/ |
| 41 | + |
22 | 42 | namespace Benchmarks.Logs
|
23 | 43 | {
|
24 | 44 | [MemoryDiagnoser]
|
@@ -62,25 +82,37 @@ public LogBenchmarks()
|
62 | 82 | [Benchmark]
|
63 | 83 | public void NoListener()
|
64 | 84 | {
|
65 |
| - this.loggerWithNoListener.LogInformation("Hello, World!"); |
| 85 | + this.loggerWithNoListener.LogInformation("Hello from {name} {price}.", "tomato", 2.99); |
| 86 | + } |
| 87 | + |
| 88 | + [Benchmark] |
| 89 | + public void NoListenerWithLoggerMessageGenerator() |
| 90 | + { |
| 91 | + Food.SayHello(this.loggerWithNoListener, "tomato", 2.99); |
66 | 92 | }
|
67 | 93 |
|
68 | 94 | [Benchmark]
|
69 | 95 | public void OneProcessor()
|
70 | 96 | {
|
71 |
| - this.loggerWithOneProcessor.LogInformation("Hello, World!"); |
| 97 | + this.loggerWithOneProcessor.LogInformation("Hello from {name} {price}.", "tomato", 2.99); |
| 98 | + } |
| 99 | + |
| 100 | + [Benchmark] |
| 101 | + public void OneProcessorWithLoggerMessageGenerator() |
| 102 | + { |
| 103 | + Food.SayHello(this.loggerWithOneProcessor, "tomato", 2.99); |
72 | 104 | }
|
73 | 105 |
|
74 | 106 | [Benchmark]
|
75 | 107 | public void TwoProcessors()
|
76 | 108 | {
|
77 |
| - this.loggerWithTwoProcessors.LogInformation("Hello, World!"); |
| 109 | + this.loggerWithTwoProcessors.LogInformation("Hello from {name} {price}.", "tomato", 2.99); |
78 | 110 | }
|
79 | 111 |
|
80 | 112 | [Benchmark]
|
81 | 113 | public void ThreeProcessors()
|
82 | 114 | {
|
83 |
| - this.loggerWithThreeProcessors.LogInformation("Hello, World!"); |
| 115 | + this.loggerWithThreeProcessors.LogInformation("Hello from {name} {price}.", "tomato", 2.99); |
84 | 116 | }
|
85 | 117 |
|
86 | 118 | internal class DummyLogProcessor : BaseProcessor<LogRecord>
|
|
0 commit comments