Skip to content

Use one parameter as a baseline for others? #2342

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

Closed
bbrk24 opened this issue Jun 26, 2023 · 3 comments
Closed

Use one parameter as a baseline for others? #2342

bbrk24 opened this issue Jun 26, 2023 · 3 comments

Comments

@bbrk24
Copy link

bbrk24 commented Jun 26, 2023

The documentation for baselines says to use [Benchmark(Baseline = true)] for baselines. Would it be possible to set a specific parameter value as the baseline instead?

I can't use multiple benchmark methods, since the value is needed to perform some setup that I don't want to be timed -- something like this:

public class ExampleBenchmark
{
  [Params(0, 100, 1000)]
  public int CacheSize { get; set; }

  [GlobalSetup]
  public void SetUpCache() =>
    AllocateCache(CacheSize);

  [Benchmark]
  public void Benchmark() =>
    DoSomethingWithCache();

  // ...
}

I can't allocate the cache in the benchmark method, since it's not relevant to what I'm trying to measure and how long it takes is more variable than the rest of the code. Yet, if I want to ensure that the cache matters -- e.g. use CacheSize=0 as the baseline and see that CacheSize=1000 runs faster -- it seems like I have to.

Would it be possible to support making the baseline a certain parameter value?

@YegorStepanov
Copy link
Contributor

#881:

No, there is no way to do that as of today.

API proposals: #431 #654 Would such APIs be useful to you?

@bbrk24
Copy link
Author

bbrk24 commented Jun 26, 2023

Yes, this is a duplicate of #881. As I understand it, the API proposed in #431 would be helpful, but #654 would be less beneficial for our use-case.

@adamsitnik
Copy link
Member

Closing as a duplicate of #881, let's keep the discussion going on there.

@adamsitnik adamsitnik closed this as not planned Won't fix, can't repro, duplicate, stale Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants