mod.rs
This file
Path
src/benchmark/mod.rs
483 lines · 16.1 KiB · Rust
Last changed by
Merge pull request #969 from sharkdp/codex/result-measurementsDavid Peterbefore adoptione689520
History of this fileTake it
The walk stopped after 200 commits: lines older than acf156e point at it.
ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 1–2why, one step back1pub mod benchmark_result;2pub mod executor;Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 3why, one step back3pub mod measurement;ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 4–7why, one step back4pub mod relative_speed;5pub mod scheduler;67use std::cmp;Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 8why, one step back8use std::io::{self, Write};ran cargo fmtHumble Penguinbefore adoptionacf156e
line 9why, one step back9Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 10why, one step back10use crate::benchmark::executor::BenchmarkIteration;ran cargo fmtHumble Penguinbefore adoptionacf156e
line 11why, one step back11use crate::command::Command;Multiple output policiesDavid Peterbefore adoption99d24b7
lines 12–14why, one step back12use crate::options::{13 CmdFailureAction, CommandOutputPolicy, ExecutorKind, Options, OutputStyleOption,14};Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
line 15why, one step back15use crate::outlier_detection::OUTLIER_THRESHOLD;Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 16why, one step back16use crate::output::console_writeln;ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 17–19why, one step back17use crate::output::progress_bar::get_progress_bar;18use crate::output::warnings::{OutlierWarningOptions, Warnings};19use crate::parameter::ParameterNameAndValue;Merge pull request #969 from sharkdp/codex/result-measurementsDavid Peterbefore adoptione689520
line 20why, one step back20use crate::quantity::{const_time_from_seconds, ratio, FormatQuantity, Time, Zero};Merge pull request #968 from sharkdp/codex/parameter-metadataDavid Peterbefore adoption05de077
line 21why, one step back21use benchmark_result::{BenchmarkResult, Parameter};Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
line 22why, one step back22use measurement::{Measurement, Measurements};ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 23–29why, one step back2324use anyhow::{anyhow, Result};25use colored::*;2627use self::executor::Executor;2829/// Threshold for warning about fast execution timeMerge pull request #961 from sharkdp/codex/uom-quantitiesDavid Peterbefore adoption975a25c
line 30why, one step back30pub const MIN_EXECUTION_TIME: Time = const_time_from_seconds(5e-3);ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 31–58why, one step back3132pub struct Benchmark<'a> {33 number: usize,34 command: &'a Command<'a>,35 options: &'a Options,36 executor: &'a dyn Executor,37}3839impl<'a> Benchmark<'a> {40 pub fn new(41 number: usize,42 command: &'a Command<'a>,43 options: &'a Options,44 executor: &'a dyn Executor,45 ) -> Self {46 Benchmark {47 number,48 command,49 options,50 executor,51 }52 }5354 /// Run setup, cleanup, or preparation commands55 fn run_intermediate_command(56 &self,57 command: &Command<'_>,58 error_output: &'static str,Multiple output policiesDavid Peterbefore adoption99d24b7
line 59why, one step back59 output_policy: &CommandOutputPolicy,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 60why, one step back60 iteration: executor::BenchmarkIteration,Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 61why, one step back61 ) -> Result<Measurement> {ran cargo fmtHumble Penguinbefore adoptionacf156e
line 62why, one step back62 self.executorAdd iteration information to failure error messageDavid Peterbefore adoption83f04cd
lines 63–64why, one step back63 .run_command_and_measure(64 command,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 65why, one step back65 iteration,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 66why, one step back66 Some(CmdFailureAction::RaiseError),Multiple output policiesDavid Peterbefore adoption99d24b7
line 67why, one step back67 output_policy,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 68why, one step back68 )ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 69–75why, one step back69 .map_err(|_| anyhow!(error_output))70 }7172 /// Run the command specified by `--setup`.73 fn run_setup_command(74 &self,75 parameters: impl IntoIterator<Item = ParameterNameAndValue<'a>>,Multiple output policiesDavid Peterbefore adoption99d24b7
line 76why, one step back76 output_policy: &CommandOutputPolicy,Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 77why, one step back77 ) -> Result<Measurement> {ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 78–87why, one step back78 let command = self79 .options80 .setup_command81 .as_ref()82 .map(|setup_command| Command::new_parametrized(None, setup_command, parameters));8384 let error_output = "The setup command terminated with a non-zero exit code. \85 Append ' || true' to the command if you are sure that this can be ignored.";8687 Ok(commandMerge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
lines 88–95why, one step back88 .map(|cmd| {89 self.run_intermediate_command(90 &cmd,91 error_output,92 output_policy,93 BenchmarkIteration::NonBenchmarkRun,94 )95 })ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 96–103why, one step back96 .transpose()?97 .unwrap_or_default())98 }99100 /// Run the command specified by `--cleanup`.101 fn run_cleanup_command(102 &self,103 parameters: impl IntoIterator<Item = ParameterNameAndValue<'a>>,Multiple output policiesDavid Peterbefore adoption99d24b7
line 104why, one step back104 output_policy: &CommandOutputPolicy,Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 105why, one step back105 ) -> Result<Measurement> {ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 106–115why, one step back106 let command = self107 .options108 .cleanup_command109 .as_ref()110 .map(|cleanup_command| Command::new_parametrized(None, cleanup_command, parameters));111112 let error_output = "The cleanup command terminated with a non-zero exit code. \113 Append ' || true' to the command if you are sure that this can be ignored.";114115 Ok(commandMerge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
lines 116–123why, one step back116 .map(|cmd| {117 self.run_intermediate_command(118 &cmd,119 error_output,120 output_policy,121 BenchmarkIteration::NonBenchmarkRun,122 )123 })ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 124–128why, one step back124 .transpose()?125 .unwrap_or_default())126 }127128 /// Run the command specified by `--prepare`.Multiple output policiesDavid Peterbefore adoption99d24b7
lines 129–132why, one step back129 fn run_preparation_command(130 &self,131 command: &Command<'_>,132 output_policy: &CommandOutputPolicy,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 133why, one step back133 iteration: executor::BenchmarkIteration,Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 134why, one step back134 ) -> Result<Measurement> {ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 135–137why, one step back135 let error_output = "The preparation command terminated with a non-zero exit code. \136 Append ' || true' to the command if you are sure that this can be ignored.";137Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 138why, one step back138 self.run_intermediate_command(command, error_output, output_policy, iteration)ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 139–140why, one step back139 }140Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
line 141why, one step back141 /// Run the command specified by `--conclude`.Multiple output policiesDavid Peterbefore adoption99d24b7
lines 142–145why, one step back142 fn run_conclusion_command(143 &self,144 command: &Command<'_>,145 output_policy: &CommandOutputPolicy,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 146why, one step back146 iteration: executor::BenchmarkIteration,Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 147why, one step back147 ) -> Result<Measurement> {Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 148–150why, one step back148 let error_output = "The conclusion command terminated with a non-zero exit code. \149 Append ' || true' to the command if you are sure that this can be ignored.";150Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 151why, one step back151 self.run_intermediate_command(command, error_output, output_policy, iteration)Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 152–153why, one step back152 }153ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 154–156why, one step back154 /// Run the benchmark for a single command155 pub fn run(&self) -> Result<BenchmarkResult> {156 if self.options.output_style != OutputStyleOption::Disabled {Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
lines 157–158why, one step back157 console_writeln!(158 io::stdout(),ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 159–161why, one step back159 "{}{}: {}",160 "Benchmark ".bold(),161 (self.number + 1).to_string().bold(),Show unused parameters in command namesDavid Peterbefore adoptiona875276
line 162why, one step back162 self.command.get_name_with_unused_parameters(),Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 163why, one step back163 )?;ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 164–165why, one step back164 }165Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
line 166why, one step back166 let mut measurements = Measurements::default();ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 167–168why, one step back167 let mut all_succeeded = true;168Multiple output policiesDavid Peterbefore adoption99d24b7
lines 169–170why, one step back169 let output_policy = &self.options.command_output_policies[self.number];170ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 171–182why, one step back171 let preparation_command = self.options.preparation_command.as_ref().map(|values| {172 let preparation_command = if values.len() == 1 {173 &values[0]174 } else {175 &values[self.number]176 };177 Command::new_parametrized(178 None,179 preparation_command,180 self.command.get_parameters().iter().cloned(),181 )182 });Multiple output policiesDavid Peterbefore adoption99d24b7
line 183why, one step back183Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 184why, one step back184 let run_preparation_command = |iteration: executor::BenchmarkIteration| {ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 185–186why, one step back185 preparation_command186 .as_ref()Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 187why, one step back187 .map(|cmd| self.run_preparation_command(cmd, output_policy, iteration))ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 188–190why, one step back188 .transpose()189 };190Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 191–202why, one step back191 let conclusion_command = self.options.conclusion_command.as_ref().map(|values| {192 let conclusion_command = if values.len() == 1 {193 &values[0]194 } else {195 &values[self.number]196 };197 Command::new_parametrized(198 None,199 conclusion_command,200 self.command.get_parameters().iter().cloned(),201 )202 });Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 203why, one step back203 let run_conclusion_command = |iteration: executor::BenchmarkIteration| {Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 204–205why, one step back204 conclusion_command205 .as_ref()Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 206why, one step back206 .map(|cmd| self.run_conclusion_command(cmd, output_policy, iteration))Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 207–209why, one step back207 .transpose()208 };209Multiple output policiesDavid Peterbefore adoption99d24b7
line 210why, one step back210 self.run_setup_command(self.command.get_parameters().iter().cloned(), output_policy)?;ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 211–223why, one step back211212 // Warmup phase213 if self.options.warmup_count > 0 {214 let progress_bar = if self.options.output_style != OutputStyleOption::Disabled {215 Some(get_progress_bar(216 self.options.warmup_count,217 "Performing warmup runs",218 self.options.output_style,219 ))220 } else {221 None222 };223Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 224why, one step back224 for i in 0..self.options.warmup_count {Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
lines 225–226why, one step back225 let warmup_iteration = BenchmarkIteration::Warmup(i);226 let _ = run_preparation_command(warmup_iteration)?;Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
lines 227–228why, one step back227 let _ = self.executor.run_command_and_measure(228 self.command,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 229why, one step back229 warmup_iteration,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 230why, one step back230 None,Multiple output policiesDavid Peterbefore adoption99d24b7
line 231why, one step back231 output_policy,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 232why, one step back232 )?;Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 233why, one step back233 let _ = run_conclusion_command(warmup_iteration)?;ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 234–253why, one step back234 if let Some(bar) = progress_bar.as_ref() {235 bar.inc(1)236 }237 }238 if let Some(bar) = progress_bar.as_ref() {239 bar.finish_and_clear()240 }241 }242243 // Set up progress bar (and spinner for initial measurement)244 let progress_bar = if self.options.output_style != OutputStyleOption::Disabled {245 Some(get_progress_bar(246 self.options.run_bounds.min,247 "Initial time measurement",248 self.options.output_style,249 ))250 } else {251 None252 };253Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
lines 254–255why, one step back254 let benchmark_iteration = BenchmarkIteration::Benchmark(0);255 let preparation_result = run_preparation_command(benchmark_iteration)?;Merge pull request #961 from sharkdp/codex/uom-quantitiesDavid Peterbefore adoption975a25c
line 256why, one step back256 let preparation_overhead = preparation_result.map_or(Time::zero(), |res| {Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
lines 257–258why, one step back257 res.time_wall_clock + self.executor.time_overhead()258 });ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 259–260why, one step back259260 // Initial timing runMerge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 261why, one step back261 let res = self.executor.run_command_and_measure(Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 262why, one step back262 self.command,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 263why, one step back263 benchmark_iteration,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 264why, one step back264 None,Multiple output policiesDavid Peterbefore adoption99d24b7
line 265why, one step back265 output_policy,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 266why, one step back266 )?;Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
line 267why, one step back267 let success = res.exit_status.success();ran cargo fmtHumble Penguinbefore adoptionacf156e
line 268why, one step back268Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 269why, one step back269 let conclusion_result = run_conclusion_command(benchmark_iteration)?;Merge pull request #961 from sharkdp/codex/uom-quantitiesDavid Peterbefore adoption975a25c
line 270why, one step back270 let conclusion_overhead = conclusion_result.map_or(Time::zero(), |res| {Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
lines 271–272why, one step back271 res.time_wall_clock + self.executor.time_overhead()272 });Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
line 273why, one step back273ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 274–275why, one step back274 // Determine number of benchmark runs275 let runs_in_min_time = (self.options.min_benchmarking_timeMerge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
line 276why, one step back276 / (res.time_wall_clockAdd --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 277–278why, one step back277 + self.executor.time_overhead()278 + preparation_overheadMerge pull request #961 from sharkdp/codex/uom-quantitiesDavid Peterbefore adoption975a25c
lines 279–280why, one step back279 + conclusion_overhead))280 .get::<ratio>() as u64;ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 281–295why, one step back281282 let count = {283 let min = cmp::max(runs_in_min_time, self.options.run_bounds.min);284285 self.options286 .run_bounds287 .max288 .as_ref()289 .map(|max| cmp::min(min, *max))290 .unwrap_or(min)291 };292293 let count_remaining = count - 1;294295 // Save the first resultMerge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
line 296why, one step back296 measurements.push(res);ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 297–308why, one step back297298 all_succeeded = all_succeeded && success;299300 // Re-configure the progress bar301 if let Some(bar) = progress_bar.as_ref() {302 bar.set_length(count)303 }304 if let Some(bar) = progress_bar.as_ref() {305 bar.inc(1)306 }307308 // Gather statistics (perform the actual benchmark)Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 309why, one step back309 for i in 0..count_remaining {Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
lines 310–311why, one step back310 let benchmark_iteration = BenchmarkIteration::Benchmark(i + 1);311 run_preparation_command(benchmark_iteration)?;ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 312–313why, one step back312313 let msg = {Merge pull request #967 from sharkdp/codex/quantity-formattingDavid Peterbefore adoptiona6c3010
lines 314–319why, one step back314 let t_wall_clock_mean = measurements.time_wall_clock_mean();315 let time_unit = self316 .options317 .time_unit318 .unwrap_or(t_wall_clock_mean.suitable_unit());319 let mean = t_wall_clock_mean.format(time_unit);ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 320–326why, one step back320 format!("Current estimate: {}", mean.to_string().green())321 };322323 if let Some(bar) = progress_bar.as_ref() {324 bar.set_message(msg.to_owned())325 }326Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 327why, one step back327 let res = self.executor.run_command_and_measure(Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 328why, one step back328 self.command,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 329why, one step back329 benchmark_iteration,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 330why, one step back330 None,Multiple output policiesDavid Peterbefore adoption99d24b7
line 331why, one step back331 output_policy,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 332why, one step back332 )?;Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
line 333why, one step back333 let success = res.exit_status.success();ran cargo fmtHumble Penguinbefore adoptionacf156e
line 334why, one step back334Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
line 335why, one step back335 measurements.push(res);ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 336–341why, one step back336337 all_succeeded = all_succeeded && success;338339 if let Some(bar) = progress_bar.as_ref() {340 bar.inc(1)341 }Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
line 342why, one step back342Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 343why, one step back343 run_conclusion_command(benchmark_iteration)?;ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 344–350why, one step back344 }345346 if let Some(bar) = progress_bar.as_ref() {347 bar.finish_and_clear()348 }349350 // Compute statistical quantitiesMerge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
lines 351–355why, one step back351 let t_num = measurements.len();352 let t_mean = measurements.time_wall_clock_mean();353 let t_stddev = measurements.stddev();354 let t_min = measurements.min();355 let t_max = measurements.max();ran cargo fmtHumble Penguinbefore adoptionacf156e
line 356why, one step back356Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
lines 357–358why, one step back357 let user_mean = measurements.time_user_mean();358 let system_mean = measurements.time_system_mean();ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 359–360why, one step back359360 // Formatting and console outputMerge pull request #967 from sharkdp/codex/quantity-formattingDavid Peterbefore adoptiona6c3010
lines 361–364why, one step back361 let time_unit = self.options.time_unit.unwrap_or(t_mean.suitable_unit());362 let mean_str = t_mean.format(time_unit);363 let min_str = t_min.format(time_unit);364 let max_str = t_max.format(time_unit);style: simplify string interpolationHamir Mahalbefore adoptionef12632
line 365why, one step back365 let num_str = format!("{t_num} runs");ran cargo fmtHumble Penguinbefore adoptionacf156e
line 366why, one step back366Merge pull request #967 from sharkdp/codex/quantity-formattingDavid Peterbefore adoptiona6c3010
lines 367–368why, one step back367 let user_str = user_mean.format(time_unit);368 let system_str = system_mean.format(time_unit);ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 369–370why, one step back369370 if self.options.output_style != OutputStyleOption::Disabled {Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 371why, one step back371 let mut stdout = io::stdout().lock();Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
line 372why, one step back372 if measurements.len() == 1 {Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
lines 373–374why, one step back373 console_writeln!(374 stdout,ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 375–380why, one step back375 " Time ({} ≡): {:>8} {:>8} [User: {}, System: {}]",376 "abs".green().bold(),377 mean_str.green().bold(),378 " ", // alignment379 user_str.blue(),380 system_str.blue()Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 381why, one step back381 )?;ran cargo fmtHumble Penguinbefore adoptionacf156e
line 382why, one step back382 } else {Merge pull request #967 from sharkdp/codex/quantity-formattingDavid Peterbefore adoptiona6c3010
line 383why, one step back383 let stddev_str = t_stddev.unwrap().format(time_unit);ran cargo fmtHumble Penguinbefore adoptionacf156e
line 384why, one step back384Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
lines 385–386why, one step back385 console_writeln!(386 stdout,ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 387–393why, one step back387 " Time ({} ± {}): {:>8} ± {:>8} [User: {}, System: {}]",388 "mean".green().bold(),389 "σ".green(),390 mean_str.green().bold(),391 stddev_str.green(),392 user_str.blue(),393 system_str.blue()Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 394why, one step back394 )?;ran cargo fmtHumble Penguinbefore adoptionacf156e
line 395why, one step back395Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
lines 396–397why, one step back396 console_writeln!(397 stdout,ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 398–403why, one step back398 " Range ({} … {}): {:>8} … {:>8} {}",399 "min".cyan(),400 "max".purple(),401 min_str.cyan(),402 max_str.purple(),403 num_str.dimmed()Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 404why, one step back404 )?;ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 405–412why, one step back405 }406 }407408 // Warnings409 let mut warnings = vec![];410411 // Check execution time412 if matches!(self.options.executor_kind, ExecutorKind::Shell(_))Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
lines 413–415why, one step back413 && measurements414 .wall_clock_times()415 .any(|t| t < MIN_EXECUTION_TIME)ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 416–419why, one step back416 {417 warnings.push(Warnings::FastExecutionTime);418 }419Spelling and grammar fixesVille Skyttäbefore adoption178bdaa
line 420why, one step back420 // Check program exit codesran cargo fmtHumble Penguinbefore adoptionacf156e
lines 421–425why, one step back421 if !all_succeeded {422 warnings.push(Warnings::NonZeroExitCode);423 }424425 // Run outlier detectionMerge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
line 426why, one step back426 let scores = measurements.modified_zscores();ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 427–440why, one step back427428 let outlier_warning_options = OutlierWarningOptions {429 warmup_in_use: self.options.warmup_count > 0,430 prepare_in_use: self431 .options432 .preparation_command433 .as_ref()434 .map(|v| v.len())435 .unwrap_or(0)436 > 0,437 };438439 if scores[0] > OUTLIER_THRESHOLD {440 warnings.push(Warnings::SlowInitialRun(Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
line 441why, one step back441 measurements.wall_clock_times().next().unwrap(),ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 442–448why, one step back442 outlier_warning_options,443 ));444 } else if scores.iter().any(|&s| s.abs() > OUTLIER_THRESHOLD) {445 warnings.push(Warnings::OutliersDetected(outlier_warning_options));446 }447448 if !warnings.is_empty() {Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
lines 449–450why, one step back449 let mut stderr = io::stderr().lock();450 console_writeln!(stderr, " ")?;ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 451–452why, one step back451452 for warning in &warnings {Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 453why, one step back453 console_writeln!(stderr, " {}: {}", "Warning".yellow(), warning)?;ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 454–457why, one step back454 }455 }456457 if self.options.output_style != OutputStyleOption::Disabled {Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 458why, one step back458 console_writeln!(io::stdout(), " ")?;ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 459–460why, one step back459 }460Multiple output policiesDavid Peterbefore adoption99d24b7
line 461why, one step back461 self.run_cleanup_command(self.command.get_parameters().iter().cloned(), output_policy)?;ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 462–463why, one step back462463 Ok(BenchmarkResult {Show unused parameters in command namesDavid Peterbefore adoptiona875276
lines 464–465why, one step back464 command: self.command.get_name(),465 command_with_unused_parameters: self.command.get_name_with_unused_parameters(),Merge pull request #969 from sharkdp/codex/result-measurementsDavid Peterbefore adoptione689520
line 466why, one step back466 measurements,ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 467–470why, one step back467 parameters: self468 .command469 .get_parameters()470 .iter()Merge pull request #968 from sharkdp/codex/parameter-metadataDavid Peterbefore adoption05de077
lines 471–479why, one step back471 .map(|(name, value)| {472 (473 name.to_string(),474 Parameter {475 value: value.to_string(),476 is_unused: self.command.is_parameter_unused(name),477 },478 )479 })ran cargo fmtHumble Penguinbefore adoptionacf156e
lines 480–483why, one step back480 .collect(),481 })482 }483}