3

How can I add extra informationto extend the summary information produced by BenchmarkDotNet?
Like:

  • current host name or
  • current (Git) branch name

I would like to achieve something similar to this example:

Host MachineName: <Environment.MachineName>
Branch: <Git-Branch-Name>

BenchmarkDotNet=v0.13.1, OS=Windows 10...
Intel Core i7...
  [Host] : .NET Framework 4.8 (4.8.4300.0), X64 RyuJIT
  Dry    : .NET Framework 4.8 (4.8.4300.0), X64 RyuJIT

Job=Dry  IterationCount=1  LaunchCount=1  
RunStrategy=ColdStart  UnrollFactor=1  WarmupCount=1  

|           Method |       Mean | Error | 
|----------------- |----------- |------ |
| Foo              | 1,940.3 ms |    NA |

ViktorZ
  • 901
  • 1
  • 10
  • 26
  • If it doesn't have to be part of the call to BenchmarkRunner.Run, you could just do some Console.WriteLine calls beforehand with the appropriate data. E.g. use https://learn.microsoft.com/en-us/dotnet/api/system.environment.getenvironmentvariable?view=net-6.0 to get environment variables. – Andrew McClement Nov 19 '21 at 16:54
  • The generated summary is output to several result files in addition to the console out. I want to have historical data with reference to the host machine, branch name and git commit hash of the benchmark run and having this information somewhere in the log files is not optimal at all. – ViktorZ Nov 19 '21 at 17:17

1 Answers1

2

Currently there is no way to extend the Summary with extra data. All you can do is to implement a custom column and add it to the config: https://benchmarkdotnet.org/articles/configs/columns.html

Adam Sitnik
  • 1,256
  • 11
  • 15