-
-
Notifications
You must be signed in to change notification settings - Fork 947
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
Introduce MockToolchain #2178
Introduce MockToolchain #2178
Conversation
@adamsitnik what do you think? |
2d0478d
to
bfb6a30
Compare
bfb6a30
to
7dd1b1d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it LGTM, but I believe that we could simplify it.
{ | ||
public static class MockHelper | ||
{ | ||
public static Summary Run<T>(ITestOutputHelper output) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make this method accept a mandatory Func<BenchmarkCase, List<Measurement>>
argument, pass it to MockToolchain
instance and remove the need of having a custom attribute, interface and reflection.
Sample usage could look like this:
MockHelper.Run<BenchmarkClass>(output, benchmarkCase =>
benchmarkCase.Descriptor.WorkloadMethod.Name switch
{
"Foo" => CreateFromValues(new double[] { 2, 2, 2 }),
"Bar" => CreateFromValues(new double[] { 4, 4, 4 }),
_ => throw new InvalidOperationException()
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamsitnik good idea, I like it! I rewrote the implementation, could you please check out the new version?
7dd1b1d
to
0a218ec
Compare
@adamsitnik I just merged #2268 to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, and great idea BTW!
This new toolchain allows writing simple unit tests for summary tables without a need to actually run benchmarks. The usage of the new API is shown in
RatioColumnTest
.