diff --git a/src/benchmark/executor.rs b/src/benchmark/executor.rs index e08774d..ac6577b 100644 --- a/src/benchmark/executor.rs +++ b/src/benchmark/executor.rs @@ -266,7 +266,7 @@ impl Executor for ShellExecutor<'_> { time_wall_clock: measurements.time_wall_clock_mean(), time_user: measurements.time_user_mean(), time_system: measurements.time_system_mean(), - peak_memory_usage: Information::zero(), + peak_memory_usage: measurements.peak_memory_usage_mean(), exit_status: ExitStatus::default(), }); diff --git a/src/benchmark/measurement.rs b/src/benchmark/measurement.rs index 9eaa8d0..58d522c 100644 --- a/src/benchmark/measurement.rs +++ b/src/benchmark/measurement.rs @@ -1,7 +1,7 @@ use std::process::ExitStatus; use crate::quantity::statistics::{max, mean, median, min, modified_zscores, standard_deviation}; -use crate::quantity::{second, Information, Time}; +use crate::quantity::{Information, Time}; /// Performance measurements and exit status from running a single command #[derive(Debug, Default, Copy, Clone)] @@ -77,12 +77,7 @@ impl Measurements { /// Compute modified Z-scores for the wall clock times. pub fn modified_zscores(&self) -> Vec { - modified_zscores( - &self - .wall_clock_times() - .map(|t| t.get::()) - .collect::>(), - ) + modified_zscores(&self.wall_clock_times().collect::>()) } /// The average user time. @@ -94,4 +89,8 @@ impl Measurements { pub fn time_system_mean(&self) -> Time { mean(self.measurements.iter().map(|m| m.time_system)) } + + pub fn peak_memory_usage_mean(&self) -> Information { + mean(self.measurements.iter().map(|m| m.peak_memory_usage)) + } } diff --git a/src/command.rs b/src/command.rs index 1fb5c0d..58bb830 100644 --- a/src/command.rs +++ b/src/command.rs @@ -97,10 +97,14 @@ impl<'a> Command<'a> { &self.parameters } + pub fn is_parameter_unused(&self, parameter: &str) -> bool { + !self.expression.contains(&format!("{{{parameter}}}")) + } + pub fn get_unused_parameters(&self) -> impl Iterator { self.parameters .iter() - .filter(move |(parameter, _)| !self.expression.contains(&format!("{{{parameter}}}"))) + .filter(move |(parameter, _)| self.is_parameter_unused(parameter)) } fn replace_parameters_in(&self, original: &str) -> String { diff --git a/src/outlier_detection.rs b/src/outlier_detection.rs index 422481a..e672c26 100644 --- a/src/outlier_detection.rs +++ b/src/outlier_detection.rs @@ -14,13 +14,13 @@ pub const OUTLIER_THRESHOLD: f64 = 1.4826 * 10.0; /// modified Z-score that is larger than `OUTLIER_THRESHOLD`. #[cfg(test)] pub fn num_outliers(xs: &[f64]) -> usize { - use crate::quantity::statistics::modified_zscores; + use crate::quantity::statistics::modified_zscores_f64; if xs.is_empty() { return 0; } - let scores = modified_zscores(xs); + let scores = modified_zscores_f64(xs); scores .iter() .filter(|&&s| s.abs() > OUTLIER_THRESHOLD) diff --git a/src/quantity/statistics.rs b/src/quantity/statistics.rs index 4065777..a0657a3 100644 --- a/src/quantity/statistics.rs +++ b/src/quantity/statistics.rs @@ -112,7 +112,7 @@ pub fn standard_deviation(values: &[Q], mean: Q) -> Q { /// /// References: /// - -pub fn modified_zscores(xs: &[f64]) -> Vec { +pub fn modified_zscores_f64(xs: &[f64]) -> Vec { assert!(!xs.is_empty()); // Compute sample median: @@ -131,6 +131,11 @@ pub fn modified_zscores(xs: &[f64]) -> Vec { xs.iter().map(|&x| (x - x_median) / mad).collect() } +pub fn modified_zscores(values: &[Q]) -> Vec { + let values: Vec<_> = values.iter().map(|q| q.unsafe_raw_value()).collect(); + modified_zscores_f64(&values) +} + #[cfg(test)] mod tests { use super::*;