From a86ca113a147d3b1353b62084bb7e9b854cc5d70 Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Sun, 10 Mar 2024 12:22:21 -0400 Subject: [PATCH] when printing binary stats diff, combine all unchanged rows into one --- collector/src/bin/collector.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/collector/src/bin/collector.rs b/collector/src/bin/collector.rs index cd1c5e6f3..26d2ed28d 100644 --- a/collector/src/bin/collector.rs +++ b/collector/src/bin/collector.rs @@ -1300,6 +1300,30 @@ fn print_binary_stats( } } rows.sort_by_cached_key(|row| Reverse((row.diff.abs(), row.before, row.name.clone()))); + + // Combine all unchanged rows into one. + if use_diff { + let mut unchanged_count = 0; + let mut total_unchanged = 0; + rows.retain(|row| { + if row.diff == 0 { + unchanged_count += 1; + total_unchanged += row.before; + false + } else { + true + } + }); + if total_unchanged > 0 { + rows.push(Row { + name: format!("<{unchanged_count} unchanged rows>"), + before: total_unchanged, + after: total_unchanged, + diff: 0, + }); + } + } + rows.push(Row { name: "Total".to_string(), before: total_before,