use std::process::ExitStatus; use crate::quantity::statistics::{max, mean, median, min, modified_zscores, standard_deviation}; use crate::quantity::{second, Information, Time}; /// Performance measurements and exit status from running a single command #[derive(Debug, Default, Copy, Clone)] pub struct Measurement { /// Wall clock time pub time_wall_clock: Time, /// Time spent in user mode pub time_user: Time, /// Time spent in kernel mode pub time_system: Time, /// Maximum amount of memory used pub peak_memory_usage: Information, /// The exit status of the process pub exit_status: ExitStatus, } /// Performance measurements and exit statuses for all runs of a command. #[derive(Debug, Default, Clone)] pub struct Measurements { pub measurements: Vec, } impl Measurements { pub fn len(&self) -> usize { self.measurements.len() } pub fn is_empty(&self) -> bool { self.measurements.is_empty() } pub fn push(&mut self, measurement: Measurement) { self.measurements.push(measurement); } pub fn wall_clock_times(&self) -> impl Iterator + '_ { self.measurements.iter().map(|m| m.time_wall_clock) } /// The average wall clock time. pub fn time_wall_clock_mean(&self) -> Time { mean(self.wall_clock_times()) } /// The standard deviation of wall clock times, if at least two runs were measured. pub fn stddev(&self) -> Option