feat(report): add legend to MarkdownReport output with explanation of columns

This commit is contained in:
Sergey Penkovsky
2025-08-06 22:53:33 +03:00
parent 1e6375f5ae
commit 01d82e1cd3
3 changed files with 35 additions and 9 deletions

View File

@@ -89,6 +89,17 @@ class MyBenchmark extends BenchmarkBase with BenchmarkWithScope {
---
| Benchmark | Chain Count | Depth | Mean (us) | Median | Stddev | Min | Max | N | ΔRSS(KB) | ΔPeak(KB) | PeakRSS(KB) |
| ----------------- | ----------- | ----- | --------- | ------ | ------ | ----- | ----- | - | -------- | --------- | ----------- |
| RegisterSingleton | 10 | 5 | 23.00 | 44.00 | 21.00 | 2.00 | 44.00 | 2 | 16 | 16 | 200400 |
| ChainSingleton | 10 | 5 | 42.50 | 51.00 | 8.50 | 34.00 | 51.00 | 2 | 64 | 64 | 200592 |
| ChainFactory | 10 | 5 | 42.00 | 48.00 | 6.00 | 36.00 | 48.00 | 2 | 64 | 64 | 200688 |
| AsyncChain | 10 | 5 | 49.00 | 52.00 | 3.00 | 46.00 | 52.00 | 2 | 0 | 0 | 200784 |
| Named | 10 | 5 | 1.00 | 1.00 | 0.00 | 1.00 | 1.00 | 2 | 0 | 0 | 200784 |
| Override | 10 | 5 | 1.50 | 2.00 | 0.50 | 1.00 | 2.00 | 2 | 0 | 0 | 200800 |
---
## License
MIT

View File

@@ -54,13 +54,13 @@ class BenchmarkCliRunner {
'benchmark': 'Universal_$bench',
'chainCount': c,
'nestingDepth': d,
'mean_us': mean.round(),
'median_us': median.round(),
'stddev_us': stddev.round(),
'min_us': minVal.round(),
'max_us': maxVal.round(),
'mean_us': mean.toStringAsFixed(2),
'median_us': median.toStringAsFixed(2),
'stddev_us': stddev.toStringAsFixed(2),
'min_us': minVal.toStringAsFixed(2),
'max_us': maxVal.toStringAsFixed(2),
'trials': timings.length,
'timings_us': timings.map((t) => t.round()).toList(),
'timings_us': timings.map((t) => t.toStringAsFixed(2)).toList(),
'memory_diff_kb': benchResult.memoryDiffKb,
'delta_peak_kb': benchResult.deltaPeakKb,
'peak_rss_kb': benchResult.peakRssKb,

View File

@@ -45,12 +45,27 @@ class MarkdownReport extends ReportGenerator {
});
String rowToLine(List<String> row, {String sep = ' | '}) =>
'| ' + List.generate(row.length, (i) => row[i].padRight(widths[i])).join(sep) + ' |';
'| ${List.generate(row.length, (i) => row[i].padRight(widths[i])).join(sep)} |';
final headerLine = rowToLine(headers);
final divider = '| ' + widths.map((w) => '-' * w).join(' | ') + ' |';
final divider = '| ${widths.map((w) => '-' * w).join(' | ')} |';
final lines = dataRows.map(rowToLine).toList();
return ([headerLine, divider] + lines).join('\n');
final legend = '''
> **Legend:**
> `Benchmark` Test name
> `Chain Count` Number of independent chains
> `Depth` Depth of each chain
> `Mean (us)` Average time per run (microseconds)
> `Median` Median time per run
> `Stddev` Standard deviation
> `Min`, `Max` Min/max run time
> `N` Number of measurements
> `ΔRSS(KB)` Change in process memory (KB)
> `ΔPeak(KB)` Change in peak RSS (KB)
> `PeakRSS(KB)` Max observed RSS memory (KB)
''';
return '$legend\n\n${([headerLine, divider] + lines).join('\n')}' ;
}
}