BenchmarkDotNet
BenchmarkDotNet copied to clipboard
Fluent API improvements
In my benchmark project I developed a small framework to improve fluent configuration of benchmarks. With this improvements I can configure benchmark like this
var pointHitTestJob = CreateJob();
var pointHitTestRunInfo = BenchmarkRunInfoBuilder
.Create()
.AddCase<SimplePointInBoundsBenchmark>(
pointHitTestJob,
caseCfg => caseCfg
.WithWorkload(_ => _.PointHitTest())
.WithGlobalSetup(_ => _.GlobalSetup())
.WithIterationSetup(_ => _.IterationSetup()))
.AddCases<QuadTreePickInPointBenchmark>(
pointHitTestJob,
caseCfg => caseCfg
.WithWorkload(_ => _.PointHitTest())
.WithGlobalSetup(_ => _.GlobalSetup())
.WithIterationSetup(_ => _.IterationSetup())
.WithParameterValues(_ => _.MaxDepth, 1, 2, 3, 4, 5)
.WithParameterValues(_ => _.NodeSize, 256, 512, 1024))
.Build(immutableCfg);
With this configuration method there's no need in any attributes in benchmark classes. So, if there's any sense, I can make PR to merge my developments.
@ds1709 thank you for your proposal! I like your idea, but I am worried that it would make our config system even more complex than it is today (attributes, command line args, custom types). @AndreyAkinshin what do you think?
I also like the idea.
I am worried that it would make our config system even more complex than it is today (attributes, command line args, custom types)
It's a valid concern. I guess we could merge it if it doesn't introduce too many complications in the config system. @ds1709 could we check out the implementation your fluent framework somewhere? It would be nice if we can take a look on it before you start working on a proper PR.
@AndreyAkinshin, sure. https://github.com/ugparu/Ugpa.QuadTree/tree/master/benchmark/Ugpa.QuadTree.Benchmark/Configuration It's small draft solution, developed for my own purposes. If it's acceptable, I can expand solution to support more scenarios.