Params
You can mark one or several fields or properties in your class by the Params
attribute. In this attribute, you can specify set of values.
As a result, you will get results for each combination of params values.
Example
public class IntroParams
{
[Params(100, 200)]
public int A { get; set; }
[Params(10, 20)]
public int B { get; set; }
[Benchmark]
public void Benchmark()
{
Thread.Sleep(A + B + 5);
}
}
Method | Median | StdDev | A | B |
---|---|---|---|---|
Benchmark | 115.3325 ms | 0.0242 ms | 100 | 10 |
Benchmark | 125.3282 ms | 0.0245 ms | 100 | 20 |
Benchmark | 215.3024 ms | 0.0375 ms | 200 | 10 |
Benchmark | 225.2710 ms | 0.0434 ms | 200 | 20 |