Skip to content

Ability to make Argument depends on the Param values #773

Description

@kant2002

During migration of the benchmarks to BDN here : dotnet/corefxlab#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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions