From 674b5422ab5c68d05933be535c59af3d24e16ef7 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Thu, 15 Oct 2020 22:12:56 +0200 Subject: [PATCH] Fix outlier detection for "fast outliers" closes #329 --- CHANGELOG.md | 1 + src/hyperfine/benchmark.rs | 2 +- src/hyperfine/outlier_detection.rs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aaef12f..8d8f513 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ ## Bugfixes +- Fix a bug in the outlier detection which would only detect "slow outliers" but not the fast ones (runs that are much faster than the rest of the benchmarking runs), see #329 - Keep output colorized when the output is not interactive and `--style=full` or `--style=color` is used. ## Other diff --git a/src/hyperfine/benchmark.rs b/src/hyperfine/benchmark.rs index f2de69d..fefe87e 100644 --- a/src/hyperfine/benchmark.rs +++ b/src/hyperfine/benchmark.rs @@ -392,7 +392,7 @@ pub fn run_benchmark( let scores = modified_zscores(×_real); if scores[0] > OUTLIER_THRESHOLD { warnings.push(Warnings::SlowInitialRun(times_real[0])); - } else if scores.iter().any(|&s| s > OUTLIER_THRESHOLD) { + } else if scores.iter().any(|&s| s.abs() > OUTLIER_THRESHOLD) { warnings.push(Warnings::OutliersDetected); } diff --git a/src/hyperfine/outlier_detection.rs b/src/hyperfine/outlier_detection.rs index 5aa4eb5..e3cfcd5 100644 --- a/src/hyperfine/outlier_detection.rs +++ b/src/hyperfine/outlier_detection.rs @@ -12,7 +12,7 @@ use statistical::median; pub const OUTLIER_THRESHOLD: f64 = 1.4826 * 10.0; /// Compute modifized Z-scores for a given sample. A (unmodified) Z-score is defined by -/// `(x_i - x_mean)/x_stddev` whereas the modified Z-score is defined by `|x_i - x_median|/MAD` +/// `(x_i - x_mean)/x_stddev` whereas the modified Z-score is defined by `(x_i - x_median)/MAD` /// where MAD is the median average deviation. /// /// References: