aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalisa Smith <malisa.tsmith@gmail.com>2016-07-07 13:08:20 -0700
committerMalisa Smith <malisa.tsmith@gmail.com>2016-07-07 13:08:20 -0700
commite1092b8b1da4c7c9c778457b0b06c6fa82058078 (patch)
tree0485ce3c5f37132256c2ce838337a329309ca9bf
parent7dccf09ff6800c7da2e50bcccc663f39bdec369f (diff)
downloadservo-e1092b8b1da4c7c9c778457b0b06c6fa82058078.tar.gz
servo-e1092b8b1da4c7c9c778457b0b06c6fa82058078.zip
simplifying min and max calculation for profiler get_statistics function
-rw-r--r--components/profile/time.rs5
-rw-r--r--tests/unit/profile/time.rs2
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::<f64>() / (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() {