From 3da71674d48640276bebba495fad555e8c9666d6 Mon Sep 17 00:00:00 2001 From: Sergey Penkovsky Date: Wed, 6 Aug 2025 22:35:49 +0300 Subject: [PATCH] chore: fix current status, all implemented features and refactors --- benchmark_cherrypick/README.ru.md | 11 ++++++ .../lib/cli/benchmark_cli.dart | 3 ++ .../lib/cli/report/pretty_report.dart | 35 +++++++++++++++++-- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/benchmark_cherrypick/README.ru.md b/benchmark_cherrypick/README.ru.md index f8a6c6d..9d48f0b 100644 --- a/benchmark_cherrypick/README.ru.md +++ b/benchmark_cherrypick/README.ru.md @@ -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 | 24 | 45 | 22 | 2 | 45 | 2 | 0 | 0 | 199232 | +| ChainSingleton | 10 | 5 | 41 | 45 | 4 | 37 | 45 | 2 | 0 | 0 | 199296 | +| ChainFactory | 10 | 5 | 43 | 50 | 8 | 35 | 50 | 2 | 0 | 0 | 199296 | +| AsyncChain | 10 | 5 | 49 | 50 | 2 | 47 | 50 | 2 | 0 | 0 | 199344 | +| Named | 10 | 5 | 1 | 1 | 0 | 1 | 1 | 2 | 0 | 0 | 199344 | +| Override | 10 | 5 | 2 | 2 | 1 | 1 | 2 | 2 | 0 | 0 | 199360 | + +--- + ## Лицензия MIT diff --git a/benchmark_cherrypick/lib/cli/benchmark_cli.dart b/benchmark_cherrypick/lib/cli/benchmark_cli.dart index 406be3e..83d2485 100644 --- a/benchmark_cherrypick/lib/cli/benchmark_cli.dart +++ b/benchmark_cherrypick/lib/cli/benchmark_cli.dart @@ -1,5 +1,7 @@ import 'dart:math'; +import 'package:benchmark_cherrypick/cli/report/markdown_report.dart'; + import '../scenarios/universal_chain_module.dart'; import 'report/pretty_report.dart'; import 'report/csv_report.dart'; @@ -70,6 +72,7 @@ class BenchmarkCliRunner { 'pretty': PrettyReport(), 'csv': CsvReport(), 'json': JsonReport(), + 'markdown': MarkdownReport(), }; print(reportGenerators[config.format]?.render(results) ?? PrettyReport().render(results)); } diff --git a/benchmark_cherrypick/lib/cli/report/pretty_report.dart b/benchmark_cherrypick/lib/cli/report/pretty_report.dart index 66dd2de..70d80a7 100644 --- a/benchmark_cherrypick/lib/cli/report/pretty_report.dart +++ b/benchmark_cherrypick/lib/cli/report/pretty_report.dart @@ -6,10 +6,39 @@ class PrettyReport extends ReportGenerator { 'benchmark','chainCount','nestingDepth','mean_us','median_us','stddev_us', 'min_us','max_us','trials','memory_diff_kb','delta_peak_kb','peak_rss_kb' ]; + + static const nameMap = { + 'Universal_UniversalBenchmark.registerSingleton': 'RegisterSingleton', + 'Universal_UniversalBenchmark.chainSingleton': 'ChainSingleton', + 'Universal_UniversalBenchmark.chainFactory': 'ChainFactory', + 'Universal_UniversalBenchmark.chainAsync': 'AsyncChain', + 'Universal_UniversalBenchmark.named': 'Named', + 'Universal_UniversalBenchmark.override': 'Override', + }; + @override String render(List> rows) { - final header = keys.join('\t'); - final lines = rows.map((r) => keys.map((k) => (r[k] ?? '').toString()).join('\t')).toList(); + final headers = [ + 'Benchmark', 'Chain Count', 'Depth', 'Mean (us)', 'Median', 'Stddev', 'Min', 'Max', 'N', 'ΔRSS(KB)', 'ΔPeak(KB)', 'PeakRSS(KB)' + ]; + final header = headers.join('\t'); + final lines = rows.map((r) { + final readableName = nameMap[r['benchmark']] ?? r['benchmark']; + return [ + readableName, + r['chainCount'], + r['nestingDepth'], + r['mean_us'], + r['median_us'], + r['stddev_us'], + r['min_us'], + r['max_us'], + r['trials'], + r['memory_diff_kb'], + r['delta_peak_kb'], + r['peak_rss_kb'], + ].join('\t'); + }).toList(); return ([header] + lines).join('\n'); } -} \ No newline at end of file +}