How to have a GlobalSetup per benchmark in BenchmarkDotNet

If we are using BenchmarkDotNet and want to have a different setup method for each benchmark or groups of benchmarks this is easy to do by setting the Target or Targets value on the GlobalSetup attribute…

In the above case GlobalSetupA will run for BenchmarkA and GlobalSetupBAndC will run for both BenchmarkB and BenchmarkC. BenchmarkD has no global setup.

Leave a Reply

Your email address will not be published. Required fields are marked *