mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +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();
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue