BenchmarkDotNet
BenchmarkDotNet copied to clipboard
Ability to make Argument depends on the Param values
During migration of the benchmarks to BDN here : https://github.com/dotnet/corefxlab/pull/2333
I want that one of argument would depends on the value mapped to current Param
. For example to always to be 60% of the InputBufferSize
Approximate current code which I have to write
[Params(1000, 5000, 10000, 20000, 50000)]
public int InputBufferSize;
[Benchmark]
[Arguments(10)]
[Arguments(600)]
public void StichingRequired(int stackSize)
{
Span<byte> stackSpan = stackSize == 600 ? stackalloc byte[600 * InputBufferSize / 1000] : stackalloc byte[stackSize];
… some code
}
what I would like to have
[Params(1000, 5000, 10000, 20000, 50000)]
public int InputBufferSize;
[Benchmark]
[ArgumentsSource(nameof(StackSizes))]
public void StichingRequired(int stackSize)
{
Span<byte> stackSpan = stackalloc byte[stackSize];
… some code
}
public IEnumerabl<object[]> StackSizes()
{
yield return new object[] { 10 };
// Here for each iteration of Param this value would be reevaluated.
yield return new object[] { 600 * InputBufferSize / 1000 };
}
right now it seems that value not yet mapped to field with Param
attribute.