@@ -47,6 +47,12 @@ Future<Map<String, dynamic>> buildComparisonTreemap(File oldJson, File newJson,
4747 return treemapFromInfo (diff, format: format);
4848}
4949
50+ String formatPercent (int value, int total, {bool withSign = false }) {
51+ final p = value / total * 100.0 ;
52+ final sign = (withSign && value > 0 ) ? '+' : '' ;
53+ return '${sign }${p .toStringAsFixed (2 )}%' ;
54+ }
55+
5056void printHistogram (ProgramInfo info, Histogram histogram,
5157 {Iterable <String > prefix = const [],
5258 Iterable <String > suffix = const [],
@@ -61,10 +67,14 @@ void printHistogram(ProgramInfo info, Histogram histogram,
6167 if (wasFiltered) Text .right ('Of total' ),
6268 ], maxWidth: maxWidth);
6369
64- String formatPercent (int value, int total) {
65- final p = value / total * 100.0 ;
66- return p.toStringAsFixed (2 ) + "%" ;
67- }
70+ final visibleRows = [prefix, suffix].expand ((l) => l).toList ();
71+ final visibleSize =
72+ visibleRows.fold (0 , (sum, key) => sum + histogram.buckets[key]);
73+ final numRestRows = histogram.length - (suffix.length + prefix.length);
74+ final hiddenRows = Set <String >.from (histogram.bySize)
75+ .difference (Set <String >.from (visibleRows));
76+ final interestingHiddenRows =
77+ hiddenRows.any ((k) => histogram.buckets[k] != 0 );
6878
6979 if (prefix.isNotEmpty) {
7080 for (var key in prefix) {
@@ -76,15 +86,10 @@ void printHistogram(ProgramInfo info, Histogram histogram,
7686 if (wasFiltered) formatPercent (size, totalSize),
7787 ]);
7888 }
79- table.addSeparator (
80- prefix.length < histogram.length ? Separator .Wave : Separator .Line );
89+ table.addSeparator (interestingHiddenRows ? Separator .Wave : Separator .Line );
8190 }
8291
83- final visibleSize = [prefix, suffix]
84- .expand ((l) => l)
85- .fold (0 , (sum, key) => sum + histogram.buckets[key]);
86- final numRestRows = histogram.length - (suffix.length + prefix.length);
87- if (numRestRows > 0 ) {
92+ if (interestingHiddenRows) {
8893 final totalRestBytes = histogram.totalSize - visibleSize;
8994 table.addTextSeparator (
9095 '$numRestRows more rows accounting for ${totalRestBytes }'
0 commit comments