From e1092b8b1da4c7c9c778457b0b06c6fa82058078 Mon Sep 17 00:00:00 2001 From: Malisa Smith Date: Thu, 7 Jul 2016 13:08:20 -0700 Subject: [PATCH] simplifying min and max calculation for profiler get_statistics function --- components/profile/time.rs | 5 +++-- tests/unit/profile/time.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/profile/time.rs b/components/profile/time.rs index 76ac26497e9..ca9d8070d9f 100644 --- a/components/profile/time.rs +++ b/components/profile/time.rs @@ -334,11 +334,12 @@ impl Profiler { }); let data_len = data.len(); + debug_assert!(data_len > 0); let (mean, median, min, max) = (data.iter().sum::() / (data_len as f64), data[data_len / 2], - data.iter().fold(f64::INFINITY, |a, &b| a.min(b)), - data.iter().fold(-f64::INFINITY, |a, &b| a.max(b))); + data[0], + data[data_len-1]); (mean, median, min, max) } diff --git a/tests/unit/profile/time.rs b/tests/unit/profile/time.rs index 0edbb596de4..9bae5801262 100644 --- a/tests/unit/profile/time.rs +++ b/tests/unit/profile/time.rs @@ -37,7 +37,7 @@ fn time_profiler_stats_test() { assert_eq!(13.2599, odd_max); } -#[cfg(debug)] +#[cfg(debug_assertions)] #[test] #[should_panic] fn time_profiler_unsorted_stats_test() {