From fc7191fe784087a56f0b38017be6a5f7c91a650c Mon Sep 17 00:00:00 2001 From: Mihir Nanavati Date: Tue, 17 Oct 2023 23:09:13 -0400 Subject: [PATCH] histogram: fix test for downsampling histograms The downsample() test uses both an incrementing factor for the downsampling as well as a mutable reference as the baseline. This makes the effective downsampling rate increase at a non-linear rate (1, 3, 6, ..). Fix by cloning the histogram and using a non-mutable reference as the baseline. --- histogram/src/standard.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/histogram/src/standard.rs b/histogram/src/standard.rs index 776426d1..1ead2d71 100644 --- a/histogram/src/standard.rs +++ b/histogram/src/standard.rs @@ -365,7 +365,8 @@ mod tests { percentiles.append(&mut tail); // Downsample and check the percentiles lie within error margin - for factor in 1..4 { + let h = histogram.clone(); + for factor in 1..7 { let error = histogram.config.error(); for p in &percentiles { @@ -377,7 +378,7 @@ mod tests { assert!(e < error); } - histogram = histogram.downsample(factor).unwrap(); + histogram = h.downsample(factor).unwrap(); } }