Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per-method parameterization #256

Closed
jskeet opened this issue Sep 2, 2016 · 4 comments
Closed

Per-method parameterization #256

jskeet opened this issue Sep 2, 2016 · 4 comments

Comments

@jskeet
Copy link

jskeet commented Sep 2, 2016

This is related to #60.

I've read the docs on parameterization but this seems a little clunky compared with what I'm used to for unit tests. If I want to benchmark several methods, with different sets of parameters, it's annoying to need a separate class for each method.

For unit tests, I can specify constants via attributes, and sources of parameters by name. It would be nice to have this in unit tests too, e.g.

[Benchmark]
[BenchmarkCase(10)]
[BenchmarkCase(50)]
public void Foo(int x)
{
...
}

Or:

private static readonly int[] FooValues = DoSomeComputationBecauseItsNotConstant();

[Benchmark]
[BenchmarkCaseSource(nameof(FooValues))]
public void Foo(int x)
{
...
}

Apologies if this is a duplicate...

@adamsitnik
Copy link
Member

I am going to work on some PoC

@Joe4evr
Copy link

Joe4evr commented Nov 15, 2017

private static readonly int[] FooValues = DoSomeComputationBecauseItsNotConstant();

Or something that could be constant, but it's a lot, say, Enumerable.Range(1, 1000).ToArray(). 🙃

@adamsitnik
Copy link
Member

@Joe4evr it's already implemented, currently being reviewed in #577 , should be released as part of 0.10.11

@adamsitnik adamsitnik modified the milestones: v0.10.x, v0.10.14 Mar 15, 2018
@AndreyAkinshin
Copy link
Member

@adamsitnik, hooray!

alinasmirnova pushed a commit to alinasmirnova/BenchmarkDotNet that referenced this issue Sep 22, 2018
alinasmirnova pushed a commit to alinasmirnova/BenchmarkDotNet that referenced this issue Sep 22, 2018
* Per-method parameterization, dotnet#256

* Allow mixing [Params] and [Arguments] in a single Benchmark, dotnet#256

* introduction of ArrayParam, more samples

* initialize arguments as fields in ctor to exclude overhead, load them to local vars and just pass in benchmark

* implement support of the disassembler entry method for arguments

* add error for benchmark with arguments for InProcessToolchain (no support yet), dotnet#687

* the docs about Arguments ;)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants