From 8990cabfd195a240426b9241bef8f0ece8c14e8e Mon Sep 17 00:00:00 2001 From: Joonatan Saarhelo Date: Fri, 11 Oct 2024 21:24:30 +0200 Subject: [PATCH] show less N/A --- .../src/bin/compare_iai_results.rs | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/core/tests/vm-benchmark/src/bin/compare_iai_results.rs b/core/tests/vm-benchmark/src/bin/compare_iai_results.rs index faf72a18f451..c274b039c9bd 100644 --- a/core/tests/vm-benchmark/src/bin/compare_iai_results.rs +++ b/core/tests/vm-benchmark/src/bin/compare_iai_results.rs @@ -25,14 +25,7 @@ fn main() { .keys() .collect::>() .intersection(&iai_after.keys().collect()) - .filter_map(|&name| { - let diff = percent_difference(iai_before[name], iai_after[name]); - if diff.abs() > 2. { - Some((name, format!("{:+.1}%", diff))) - } else { - None - } - }) + .map(|&name| (name, percent_difference(iai_before[name], iai_after[name]))) .collect::>(); let duration_changes = opcodes_before @@ -47,12 +40,17 @@ fn main() { let mut nonzero_diff = false; - for name in perf_changes.keys().collect::>().union( - &duration_changes - .iter() - .filter_map(|(key, value)| (*value != 0).then_some(key)) - .collect(), - ) { + for name in perf_changes + .iter() + .filter_map(|(key, value)| (value.abs() > 2.).then_some(key)) + .collect::>() + .union( + &duration_changes + .iter() + .filter_map(|(key, value)| (*value != 0).then_some(key)) + .collect(), + ) + { // write the header before writing the first line of diff if !nonzero_diff { println!("Benchmark name | change in estimated runtime | change in number of opcodes executed \n--- | --- | ---"); @@ -63,7 +61,10 @@ fn main() { println!( "{} | {} | {}", name, - perf_changes.get(**name).unwrap_or(&n_a.clone()), + perf_changes + .get(**name) + .map(|percent| format!("{:+.1}%", percent)) + .unwrap_or(n_a.clone()), duration_changes .get(**name) .map(|abs_diff| format!(