I want to use BenchmarkDotNet to run benchmarks on all three Run() methods of the following classes. But it's not clear what the syntax should be.
class Class1
{
[Benchmark]
public bool Run(ref string[] columns)
{
// ...
}
}
class Class2
{
[Benchmark]
public bool Run(ref string[] columns)
{
// ...
}
}
class Class3
{
[Benchmark]
public bool Run(ref string[] columns)
{
// ...
}
}
I tried syntax like this.
BenchmarkRunner.Run<Class1>();
But this gives me an error.
Benchmark method ReadRow has incorrect signature.
Method shouldn't have any arguments.
Questions: To compare the performance of these three methods:
- How do I satisfy the argument requirements and eliminate this error?
- How do I compare the performance of the methods? Do I simply call
BenchmarkRunner.Run<Class1>()for each class, sequentially?
Create class containing parameterless benchmark method and invoke the becnhmarked method there passing parameters. Either create the param in-place or use some precreated ones:
Also check the docs articles on:
If needed approaches specified there will allow to move instance and parameter creation out of the benchmarked methods.
Move all method inside one benchmark class.