Open filzrev opened 1 month ago
When using ThreadingDiagnoser/ExceptionDiagnoser. Following metric columns are displayed always .
ThreadingDiagnoser
ExceptionDiagnoser
Exceptions
Completed Work Items
Lock Contentions
Is it able to automatically hide these columns if all metric values are 0 ?.
0
It seems to be able to change behaviors by modifying following code.
Excample benchmark code
[ShortRunJob] [ThreadingDiagnoser] // [HideColumns(Column.CompletedWorkItems, Column.LockContentions, Column.Exceptions)] public class Benchmarks { [Benchmark] public void Benchmark() { Thread.Sleep(1); } }
Console Output
| Method | Mean | Error | StdDev | Exceptions | Completed Work Items | Lock Contentions | |---------- |---------:|---------:|---------:|-----------:|---------------------:|-----------------:| | Benchmark | 15.57 ms | 0.364 ms | 0.020 ms | - | - | - |
It should be fairly easy to implement that behavior by changing the implementation of GetIsAvailable for those metric descriptors, similar to MemoryDiagnoser.
GetIsAvailable
MemoryDiagnoser
https://github.com/dotnet/BenchmarkDotNet/blob/ca5dfdf106affb0922f5b8002a67272a27d3fd03/src/BenchmarkDotNet/Diagnosers/MemoryDiagnoser.cs#L69
https://github.com/dotnet/BenchmarkDotNet/blob/ca5dfdf106affb0922f5b8002a67272a27d3fd03/src/BenchmarkDotNet/Diagnosers/ThreadingDiagnoser.cs#L65
https://github.com/dotnet/BenchmarkDotNet/blob/ca5dfdf106affb0922f5b8002a67272a27d3fd03/src/BenchmarkDotNet/Diagnosers/ThreadingDiagnoser.cs#L80
https://github.com/dotnet/BenchmarkDotNet/blob/ca5dfdf106affb0922f5b8002a67272a27d3fd03/src/BenchmarkDotNet/Diagnosers/ExceptionDiagnoser.cs#L52
When using
ThreadingDiagnoser
/ExceptionDiagnoser
. Following metric columns are displayed always .Exceptions
Completed Work Items
Lock Contentions
Is it able to automatically hide these columns if all metric values are
0
?.It seems to be able to change behaviors by modifying following code.
Excample benchmark code
Console Output