runRegistered function
Measures every benchmark declared with benchmark that has not run yet,
as one table with a group per group, and returns it; null when there
are none. Declared benchmarks run on their own after main returns, so
call this only to run them earlier or to get the table.
Implementation
Future<Comparison?> runRegistered() async {
if (_entries.isEmpty) return null;
final entries = List.of(_entries);
_entries.clear();
final groups = <String, List<Benchmark>>{};
var sized = true;
for (final e in entries) {
groups
.putIfAbsent(e.group.isEmpty ? 'Benchmarks' : e.group, () => [])
.add(e.benchmark);
if (e.benchmark.size <= 0) sized = false;
}
final metric = sized ? Metric.throughput : Metric.rate;
final settings = BenchmarkSettings.current;
return runComparison(
columns: [metric.name],
groups: {for (final e in groups.entries) e.key: (c) => e.value},
metric: metric,
out: settings.out ?? platform.standardOutput(),
renderer: settings.renderer ?? const TextTableRenderer(),
);
}