-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TESTS]Added BenchmarkDotNet debug helper #4717
Conversation
Datadog ReportBranch report: ❌ ❌ Failed Tests (1)
|
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing the following branches/commits: Execution-time benchmarks measure the whole time it takes to execute a program. And are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are shown in red. The following thresholds were used for comparing the execution times:
Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard. Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph). gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (4717) - mean (71ms) : 64, 79
. : milestone, 71,
master - mean (71ms) : 63, 78
. : milestone, 71,
section CallTarget+Inlining+NGEN
This PR (4717) - mean (1,002ms) : 981, 1023
. : milestone, 1002,
master - mean (998ms) : 979, 1017
. : milestone, 998,
gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (4717) - mean (106ms) : 103, 109
. : milestone, 106,
master - mean (106ms) : 103, 109
. : milestone, 106,
section CallTarget+Inlining+NGEN
This PR (4717) - mean (689ms) : 666, 712
. : milestone, 689,
master - mean (686ms) : 669, 703
. : milestone, 686,
gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (4717) - mean (90ms) : 87, 93
. : milestone, 90,
master - mean (90ms) : 87, 94
. : milestone, 90,
section CallTarget+Inlining+NGEN
This PR (4717) - mean (656ms) : 635, 678
. : milestone, 656,
master - mean (659ms) : 634, 683
. : milestone, 659,
gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (4717) - mean (187ms) : 184, 191
. : milestone, 187,
master - mean (187ms) : 184, 189
. : milestone, 187,
section CallTarget+Inlining+NGEN
This PR (4717) - mean (1,131ms) : 1110, 1152
. : milestone, 1131,
master - mean (1,127ms) : 1107, 1148
. : milestone, 1127,
gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (4717) - mean (271ms) : 267, 275
. : milestone, 271,
master - mean (271ms) : 266, 275
. : milestone, 271,
section CallTarget+Inlining+NGEN
This PR (4717) - mean (1,100ms) : 1075, 1125
. : milestone, 1100,
master - mean (1,098ms) : 1077, 1119
. : milestone, 1098,
gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (4717) - mean (262ms) : 258, 266
. : milestone, 262,
master - mean (261ms) : 258, 264
. : milestone, 261,
section CallTarget+Inlining+NGEN
This PR (4717) - mean (1,062ms) : 1031, 1092
. : milestone, 1062,
master - mean (1,064ms) : 1041, 1088
. : milestone, 1064,
|
@@ -67,6 +78,52 @@ private static void Main(string[] args) | |||
|
|||
Console.WriteLine("Running tests..."); | |||
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, config); | |||
|
|||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we check if BenchmarkSwitcher.Run
changes the Environment.ExitCode
? Maybe to play safe we can do return Environment.ExitCode;
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 1b1c7ab
@@ -8,13 +8,24 @@ | |||
using BenchmarkDotNet.Filters; | |||
using Benchmarks.Trace.DatadogProfiler; | |||
using Benchmarks.Trace.Jetbrains; | |||
using Benchmarks.Trace.Iast; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
namespace doesnt exist in the project, did you mean to add some iast benchmarks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. This is cherrypicked from the IAST micro benchmark PR. Fixed in 84c58fe
Removed unnecessary using clause
} | ||
|
||
// Retrieve the Benchmark methods | ||
var benchmarkMethods = typeof(T).GetMethods().Where(m => Attribute.GetCustomAttribute(m, typeof(BenchmarkDotNet.Attributes.BenchmarkAttribute)) != null).ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
benchmarkMethods
is unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in 204350f
Removed unused code
Datadog ReportBranch report: ✅ |
Benchmarks Report 🐌Benchmarks for #4717 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.ActivityBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Asm.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Asm.AppSecWafBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.DbCommandBenchmark - Faster 🎉 Same allocations ✔️
|
Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery‑net6.0 | 1.155 | 1,065.17 | 922.60 |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | ExecuteNonQuery |
net6.0 | 1.06μs | 0.754ns | 2.92ns | 0.0106 | 0 | 0 | 768 B |
master | ExecuteNonQuery |
netcoreapp3.1 | 1.36μs | 0.455ns | 1.76ns | 0.0103 | 0 | 0 | 768 B |
master | ExecuteNonQuery |
net472 | 1.68μs | 1.09ns | 4.2ns | 0.116 | 0 | 0 | 730 B |
#4717 | ExecuteNonQuery |
net6.0 | 922ns | 0.274ns | 1.06ns | 0.0106 | 0 | 0 | 768 B |
#4717 | ExecuteNonQuery |
netcoreapp3.1 | 1.28μs | 1.36ns | 5.27ns | 0.0104 | 0 | 0 | 768 B |
#4717 | ExecuteNonQuery |
net472 | 1.57μs | 0.563ns | 2.03ns | 0.116 | 0 | 0 | 730 B |
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | CallElasticsearch |
net6.0 | 1.11μs | 0.558ns | 2.16ns | 0.0132 | 0 | 0 | 936 B |
master | CallElasticsearch |
netcoreapp3.1 | 1.42μs | 0.669ns | 2.41ns | 0.0126 | 0 | 0 | 936 B |
master | CallElasticsearch |
net472 | 2.37μs | 0.979ns | 3.79ns | 0.151 | 0 | 0 | 955 B |
master | CallElasticsearchAsync |
net6.0 | 1.27μs | 0.478ns | 1.79ns | 0.0127 | 0 | 0 | 912 B |
master | CallElasticsearchAsync |
netcoreapp3.1 | 1.45μs | 0.501ns | 1.74ns | 0.0132 | 0 | 0 | 984 B |
master | CallElasticsearchAsync |
net472 | 2.47μs | 0.978ns | 3.66ns | 0.16 | 0 | 0 | 1.01 KB |
#4717 | CallElasticsearch |
net6.0 | 1.21μs | 0.463ns | 1.73ns | 0.0127 | 0 | 0 | 936 B |
#4717 | CallElasticsearch |
netcoreapp3.1 | 1.43μs | 0.54ns | 2.09ns | 0.0129 | 0 | 0 | 936 B |
#4717 | CallElasticsearch |
net472 | 2.34μs | 0.528ns | 1.97ns | 0.151 | 0 | 0 | 955 B |
#4717 | CallElasticsearchAsync |
net6.0 | 1.22μs | 0.461ns | 1.72ns | 0.0129 | 0 | 0 | 912 B |
#4717 | CallElasticsearchAsync |
netcoreapp3.1 | 1.47μs | 0.44ns | 1.71ns | 0.0133 | 0 | 0 | 984 B |
#4717 | CallElasticsearchAsync |
net472 | 2.44μs | 1.56ns | 6.06ns | 0.161 | 0 | 0 | 1.01 KB |
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | ExecuteAsync |
net6.0 | 1.27μs | 1.19ns | 4.46ns | 0.0127 | 0 | 0 | 912 B |
master | ExecuteAsync |
netcoreapp3.1 | 1.44μs | 0.74ns | 2.67ns | 0.0121 | 0 | 0 | 912 B |
master | ExecuteAsync |
net472 | 1.64μs | 0.939ns | 3.63ns | 0.139 | 0 | 0 | 875 B |
#4717 | ExecuteAsync |
net6.0 | 1.15μs | 0.629ns | 2.44ns | 0.0128 | 0 | 0 | 912 B |
#4717 | ExecuteAsync |
netcoreapp3.1 | 1.47μs | 0.75ns | 2.81ns | 0.0124 | 0 | 0 | 912 B |
#4717 | ExecuteAsync |
net472 | 1.69μs | 1.12ns | 4.34ns | 0.138 | 0 | 0 | 875 B |
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | SendAsync |
net6.0 | 3.7μs | 0.911ns | 3.41ns | 0.0259 | 0 | 0 | 1.9 KB |
master | SendAsync |
netcoreapp3.1 | 4.52μs | 1.23ns | 4.62ns | 0.0318 | 0 | 0 | 2.43 KB |
master | SendAsync |
net472 | 7.12μs | 2.34ns | 9.07ns | 0.473 | 0 | 0 | 2.99 KB |
#4717 | SendAsync |
net6.0 | 3.8μs | 1.38ns | 4.77ns | 0.0266 | 0 | 0 | 1.9 KB |
#4717 | SendAsync |
netcoreapp3.1 | 4.43μs | 1.42ns | 5.33ns | 0.0333 | 0 | 0 | 2.43 KB |
#4717 | SendAsync |
net472 | 7.04μs | 3.74ns | 14.5ns | 0.475 | 0 | 0 | 2.99 KB |
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | EnrichedLog |
net6.0 | 1.36μs | 0.601ns | 2.25ns | 0.0222 | 0 | 0 | 1.57 KB |
master | EnrichedLog |
netcoreapp3.1 | 1.95μs | 1.69ns | 6.33ns | 0.0211 | 0 | 0 | 1.57 KB |
master | EnrichedLog |
net472 | 2.34μs | 1.53ns | 5.94ns | 0.236 | 0 | 0 | 1.49 KB |
#4717 | EnrichedLog |
net6.0 | 1.38μs | 0.752ns | 2.91ns | 0.0221 | 0 | 0 | 1.57 KB |
#4717 | EnrichedLog |
netcoreapp3.1 | 2.08μs | 1.05ns | 4.08ns | 0.0207 | 0 | 0 | 1.57 KB |
#4717 | EnrichedLog |
net472 | 2.26μs | 1.11ns | 4.16ns | 0.236 | 0 | 0 | 1.49 KB |
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | EnrichedLog |
net6.0 | 112μs | 96ns | 359ns | 0 | 0 | 0 | 4.21 KB |
master | EnrichedLog |
netcoreapp3.1 | 117μs | 133ns | 513ns | 0.0587 | 0 | 0 | 4.21 KB |
master | EnrichedLog |
net472 | 149μs | 142ns | 550ns | 0.671 | 0.224 | 0 | 4.38 KB |
#4717 | EnrichedLog |
net6.0 | 112μs | 83.1ns | 322ns | 0 | 0 | 0 | 4.21 KB |
#4717 | EnrichedLog |
netcoreapp3.1 | 119μs | 307ns | 1.19μs | 0 | 0 | 0 | 4.21 KB |
#4717 | EnrichedLog |
net472 | 147μs | 70.8ns | 265ns | 0.654 | 0.218 | 0 | 4.38 KB |
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | EnrichedLog |
net6.0 | 2.71μs | 1.02ns | 3.82ns | 0.03 | 0 | 0 | 2.13 KB |
master | EnrichedLog |
netcoreapp3.1 | 3.91μs | 0.861ns | 3.22ns | 0.0274 | 0 | 0 | 2.13 KB |
master | EnrichedLog |
net472 | 4.5μs | 1.24ns | 4.64ns | 0.306 | 0 | 0 | 1.93 KB |
#4717 | EnrichedLog |
net6.0 | 2.78μs | 0.793ns | 2.97ns | 0.0293 | 0 | 0 | 2.13 KB |
#4717 | EnrichedLog |
netcoreapp3.1 | 3.87μs | 1.25ns | 4.85ns | 0.0288 | 0 | 0 | 2.13 KB |
#4717 | EnrichedLog |
net472 | 4.58μs | 3.34ns | 12.5ns | 0.306 | 0 | 0 | 1.93 KB |
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | SendReceive |
net6.0 | 1.33μs | 0.538ns | 2.08ns | 0.0153 | 0 | 0 | 1.1 KB |
master | SendReceive |
netcoreapp3.1 | 1.67μs | 1.06ns | 4.1ns | 0.0151 | 0 | 0 | 1.1 KB |
master | SendReceive |
net472 | 2.02μs | 1.77ns | 6.84ns | 0.177 | 0 | 0 | 1.12 KB |
#4717 | SendReceive |
net6.0 | 1.3μs | 0.967ns | 3.49ns | 0.0156 | 0 | 0 | 1.1 KB |
#4717 | SendReceive |
netcoreapp3.1 | 1.64μs | 2.56ns | 9.92ns | 0.0147 | 0 | 0 | 1.1 KB |
#4717 | SendReceive |
net472 | 2.04μs | 1.99ns | 7.71ns | 0.177 | 0 | 0 | 1.12 KB |
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | EnrichedLog |
net6.0 | 2.55μs | 5.25ns | 20.3ns | 0.0215 | 0 | 0 | 1.53 KB |
master | EnrichedLog |
netcoreapp3.1 | 3.54μs | 1.49ns | 5.76ns | 0.0213 | 0 | 0 | 1.58 KB |
master | EnrichedLog |
net472 | 4.11μs | 1.76ns | 6.81ns | 0.311 | 0 | 0 | 1.96 KB |
#4717 | EnrichedLog |
net6.0 | 2.69μs | 0.814ns | 2.82ns | 0.0214 | 0 | 0 | 1.53 KB |
#4717 | EnrichedLog |
netcoreapp3.1 | 3.57μs | 1.56ns | 6.03ns | 0.0216 | 0 | 0 | 1.58 KB |
#4717 | EnrichedLog |
net472 | 4.05μs | 6.76ns | 26.2ns | 0.311 | 0 | 0 | 1.96 KB |
Benchmarks.Trace.SpanBenchmark - Faster 🎉 Same allocations ✔️
Faster 🎉 in #4717
Benchmark
base/diff
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0
1.174
459.76
391.71
Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 | 1.174 | 459.76 | 391.71 |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | StartFinishSpan |
net6.0 | 460ns | 0.183ns | 0.709ns | 0.0076 | 0 | 0 | 536 B |
master | StartFinishSpan |
netcoreapp3.1 | 576ns | 0.209ns | 0.753ns | 0.0072 | 0 | 0 | 536 B |
master | StartFinishSpan |
net472 | 661ns | 0.351ns | 1.36ns | 0.0852 | 0 | 0 | 538 B |
master | StartFinishScope |
net6.0 | 557ns | 0.18ns | 0.696ns | 0.00922 | 0 | 0 | 656 B |
master | StartFinishScope |
netcoreapp3.1 | 728ns | 0.232ns | 0.899ns | 0.00875 | 0 | 0 | 656 B |
master | StartFinishScope |
net472 | 935ns | 0.312ns | 1.21ns | 0.0978 | 0 | 0 | 618 B |
#4717 | StartFinishSpan |
net6.0 | 392ns | 0.196ns | 0.733ns | 0.00747 | 0 | 0 | 536 B |
#4717 | StartFinishSpan |
netcoreapp3.1 | 529ns | 0.319ns | 1.11ns | 0.00745 | 0 | 0 | 536 B |
#4717 | StartFinishSpan |
net472 | 696ns | 0.163ns | 0.632ns | 0.0854 | 0 | 0 | 538 B |
#4717 | StartFinishScope |
net6.0 | 526ns | 0.422ns | 1.58ns | 0.00922 | 0 | 0 | 656 B |
#4717 | StartFinishScope |
netcoreapp3.1 | 673ns | 0.294ns | 1.14ns | 0.00887 | 0 | 0 | 656 B |
#4717 | StartFinishScope |
net472 | 853ns | 0.192ns | 0.72ns | 0.0979 | 0 | 0 | 618 B |
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | RunOnMethodBegin |
net6.0 | 615ns | 0.276ns | 1.07ns | 0.00922 | 0 | 0 | 656 B |
master | RunOnMethodBegin |
netcoreapp3.1 | 792ns | 0.445ns | 1.72ns | 0.00869 | 0 | 0 | 656 B |
master | RunOnMethodBegin |
net472 | 1.02μs | 0.604ns | 2.34ns | 0.0978 | 0 | 0 | 618 B |
#4717 | RunOnMethodBegin |
net6.0 | 661ns | 0.649ns | 2.51ns | 0.00926 | 0 | 0 | 656 B |
#4717 | RunOnMethodBegin |
netcoreapp3.1 | 830ns | 0.444ns | 1.72ns | 0.00878 | 0 | 0 | 656 B |
#4717 | RunOnMethodBegin |
net472 | 994ns | 0.244ns | 0.945ns | 0.0979 | 0 | 0 | 618 B |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not :D
Summary of changes
Implemented helper functions to launch, by using reflection, a benchmark in debug with the debugger attached.
Reason for change
BenchmarkDotNet would not allow (or make easy) to debug a benchmark.
Implementation details
Implemented reflection relying functions to discover benchmark envelope and launch it mimicking what BenchmarkDotNet would do.