mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
simplifying min and max calculation for profiler get_statistics function
This commit is contained in:
parent
7dccf09ff6
commit
e1092b8b1d
2 changed files with 4 additions and 3 deletions
|
@ -334,11 +334,12 @@ impl Profiler {
|
||||||
});
|
});
|
||||||
|
|
||||||
let data_len = data.len();
|
let data_len = data.len();
|
||||||
|
debug_assert!(data_len > 0);
|
||||||
let (mean, median, min, max) =
|
let (mean, median, min, max) =
|
||||||
(data.iter().sum::<f64>() / (data_len as f64),
|
(data.iter().sum::<f64>() / (data_len as f64),
|
||||||
data[data_len / 2],
|
data[data_len / 2],
|
||||||
data.iter().fold(f64::INFINITY, |a, &b| a.min(b)),
|
data[0],
|
||||||
data.iter().fold(-f64::INFINITY, |a, &b| a.max(b)));
|
data[data_len-1]);
|
||||||
(mean, median, min, max)
|
(mean, median, min, max)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ fn time_profiler_stats_test() {
|
||||||
assert_eq!(13.2599, odd_max);
|
assert_eq!(13.2599, odd_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(debug)]
|
#[cfg(debug_assertions)]
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn time_profiler_unsorted_stats_test() {
|
fn time_profiler_unsorted_stats_test() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue