Setting default values per group niveau
Problem to solve
Currently if you want to override the iterations
or the duration
of a benchmark, you can pass it to the function itself:
benchmark('name', () {
// ...
}, iterations: 100, duration: Duration(milliseconds: 5000));
But if you want to set that for all the benchmarks in a particular group, you can't. You'll have to pass it to each benchmark.
Proposal
My proposal is to add a few more methods to set certain default values, and they should follow the same hierarchy that is based on their group. So if a group sets the iteration value, the subgroup should also use that value:
iterations(100);
duration(Duration(milliseconds: 5000);
group('group', () {
group('sub group', () {
iterations(200);
benchmark('sub benchmark', () {
// Will run with iterations 200, and duration 5000 ms.
});
});
benchmark('benchmark', () {
// Will run with iterations 100, and duration 5000 ms.
});
});