-
-
Notifications
You must be signed in to change notification settings - Fork 983
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
Baseline and Params(Source) #881
Comments
Hello @DragonSA No, there is no way to do that as of today. However, we are open to ideas and suggestions (how should we extend our API to make it possible?) |
Regarding the API, I would suggest something like I tried to implement this manually (using |
Some thoughts:
@YegorStepanov thoughts? |
I was thinking of this also. I would do something similar to NUnit's public BenchmarkData(params object[] data) public IEnumerable<BenchmarkData> GetParams()
{
yield return new BenchmarkData(0, null) { IsBaseline = true };
yield return new BenchmarkData(42, "Hello World");
} |
Honestly, in my case, it would be beneficial to make one parameter the benchmark across all the others, something like [Params(
new(0) { IsBaseline = true },
new(1)
)]
public int X { get; set; }
[Params(2, 3)]
public int Y { get; set; } Where it uses |
@bbrk24 Multiple params are combinatorial, so how would the baseline work in that case?
[Edit] Looking at it visually, I guess they are easy to map to their respective baselines by matching the non-baseline params. What if you put a baseline on each param? [Edit] I think that would work by still mapping the non-baseline values, and the baseline benchmarks would be only a combination of both baseline values. [Params(
new(0) { IsBaseline = true },
new(1)
)]
public int X { get; set; }
[Params(
new(2) { IsBaseline = true },
new(3)
)]
public int Y { get; set; }
[Params(5, 6)]
public int Y { get; set; }
So, depending on where you put the baseline, you could have multiple baselines, or a single baseline, and the non-baseline benchmarks can be mapped to their respective baseline benchmarks. Of course, ignoring that that syntax is illegal in C# (only allows constant values in attributes), and that would have to be in |
I like this idea and the output of the table. I suggest adding [BaselineIndex(0)]
[Params(true, false)]
public bool A;
[BaselineIndex(1)]
[Params(1, 2)]
public bool B;
[Params(3, 4)]
public bool C;
// A=true B=2 is a baseline BenchmarkDatayield return new BenchmarkData(0, null) { IsBaseline = true }; Do we really need a public magic type? Unlike an attribute, it can dynamically select the baseline index, but is that usefull? |
That is necessary for [Edit] I think I misunderstood the question. Yes, I think being able to dynamically select a baseline would be useful. At worst, it won't hurt. Also, I think it makes it clearer when using |
In that case, we can add both options :) |
Could knock out 2 birds with 1 stone using the |
Is there a way to have a property set by
[Params]
or[ParamSource]
where one of the parameters is the baseline?The text was updated successfully, but these errors were encountered: