BenchmarkDotNet
BenchmarkDotNet copied to clipboard
Not Set Hardware Counter throws Argument Null Exception
Hi,
First, thank you for your effort. BenchmarkDotNet is a great tool.
Issue:
I have encountered an interesting exception.
When you set
... AddHardwareCounters(HardwareCounter.NotSet) ...
on configs,
.net throws
System.ArgumentNullException: 'Value cannot be null. (Parameter 'key')
on https://github.com/dotnet/BenchmarkDotNet/blob/34817bfdd8909711b4802415808d26849aaed98e/src/BenchmarkDotNet.Diagnostics.Windows/HardwareCounters.cs#L56
Since HardwareCounter.NotSet
is enum, there could be a proper way to handle/prevent it at
https://github.com/dotnet/BenchmarkDotNet/blob/34817bfdd8909711b4802415808d26849aaed98e/src/BenchmarkDotNet.Diagnostics.Windows/HardwareCounters.cs#L53
I believe.
If you consider to fix it, I may create a PR.
Regards, Emre
If you consider to fix it, I may create a PR.
@emreyigit A PR would be welcomed!
You might also consider filtering out HardwareCounter.NotSet
in the AddHardwareCounters
method:
https://github.com/dotnet/BenchmarkDotNet/blob/63e28c100a42a6492d09a0b93a8a4c141061bb0d/src/BenchmarkDotNet/Configs/ManualConfig.cs#L172-L175