mod.rs
This file
Path
src/benchmark/mod.rs
475 lines · 15.8 KiB · Rust
Last changed by
Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
History of this fileTake it
The walk stopped after 200 commits: lines older than ab5ae5f point at it.
Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
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;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 4–6why, one step back4pub mod scheduler;56use std::cmp;Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 7why, one step back7use std::io::{self, Write};Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
line 8why, one step back8use std::time::Instant;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
line 9why, one step back9Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 10why, one step back10use crate::benchmark::benchmark_result::Parameter;Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 11why, one step back11use crate::benchmark::executor::BenchmarkIteration;Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 12why, one step back12use crate::benchmark::measurement::{Measurement, Measurements};Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
line 13why, one step back13use crate::command::Command;Multiple output policiesDavid Peterbefore adoption99d24b7
lines 14–16why, one step back14use crate::options::{15 CmdFailureAction, CommandOutputPolicy, ExecutorKind, Options, OutputStyleOption,16};Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
line 17why, one step back17use crate::outlier_detection::OUTLIER_THRESHOLD;Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 18why, one step back18use crate::output::console_writeln;Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
line 19why, one step back19use crate::output::progress_bar::{Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
line 20why, one step back20 finish_initial_measurement, get_progress_bar, set_benchmark_header, start_initial_measurement,Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
line 21why, one step back21};Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
line 22why, one step back22use crate::output::report;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 23–24why, one step back23use crate::output::warnings::{OutlierWarningOptions, Warnings};24use crate::parameter::ParameterNameAndValue;Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
line 25why, one step back25use crate::quantity::{self, const_time_from_seconds, Time, Zero};Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 26why, one step back26use benchmark_result::BenchmarkResult;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
line 27why, one step back27Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
line 28why, one step back28use anyhow::{anyhow, ensure, Result};Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 29–33why, one step back29use colored::*;3031use self::executor::Executor;3233/// Threshold for warning about fast execution timeMerge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 34why, one step back34pub const MIN_EXECUTION_TIME: Time = const_time_from_seconds(0.005);Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 35–62why, one step back3536pub struct Benchmark<'a> {37 number: usize,38 command: &'a Command<'a>,39 options: &'a Options,40 executor: &'a dyn Executor,41}4243impl<'a> Benchmark<'a> {44 pub fn new(45 number: usize,46 command: &'a Command<'a>,47 options: &'a Options,48 executor: &'a dyn Executor,49 ) -> Self {50 Benchmark {51 number,52 command,53 options,54 executor,55 }56 }5758 /// Run setup, cleanup, or preparation commands59 fn run_intermediate_command(60 &self,61 command: &Command<'_>,62 error_output: &'static str,Multiple output policiesDavid Peterbefore adoption99d24b7
line 63why, one step back63 output_policy: &CommandOutputPolicy,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 64why, one step back64 iteration: executor::BenchmarkIteration,Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 65why, one step back65 ) -> Result<Measurement> {Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
line 66why, one step back66 self.executorAdd iteration information to failure error messageDavid Peterbefore adoption83f04cd
lines 67–68why, one step back67 .run_command_and_measure(68 command,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 69why, one step back69 iteration,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 70why, one step back70 Some(CmdFailureAction::RaiseError),Multiple output policiesDavid Peterbefore adoption99d24b7
line 71why, one step back71 output_policy,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 72why, one step back72 )Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 73–79why, one step back73 .map_err(|_| anyhow!(error_output))74 }7576 /// Run the command specified by `--setup`.77 fn run_setup_command(78 &self,79 parameters: impl IntoIterator<Item = ParameterNameAndValue<'a>>,Multiple output policiesDavid Peterbefore adoption99d24b7
line 80why, one step back80 output_policy: &CommandOutputPolicy,Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 81why, one step back81 ) -> Result<Measurement> {Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 82–91why, one step back82 let command = self83 .options84 .setup_command85 .as_ref()86 .map(|setup_command| Command::new_parametrized(None, setup_command, parameters));8788 let error_output = "The setup command terminated with a non-zero exit code. \89 Append ' || true' to the command if you are sure that this can be ignored.";9091 Ok(commandMerge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
lines 92–99why, one step back92 .map(|cmd| {93 self.run_intermediate_command(94 &cmd,95 error_output,96 output_policy,97 BenchmarkIteration::NonBenchmarkRun,98 )99 })Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 100–107why, one step back100 .transpose()?101 .unwrap_or_default())102 }103104 /// Run the command specified by `--cleanup`.105 fn run_cleanup_command(106 &self,107 parameters: impl IntoIterator<Item = ParameterNameAndValue<'a>>,Multiple output policiesDavid Peterbefore adoption99d24b7
line 108why, one step back108 output_policy: &CommandOutputPolicy,Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 109why, one step back109 ) -> Result<Measurement> {Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 110–119why, one step back110 let command = self111 .options112 .cleanup_command113 .as_ref()114 .map(|cleanup_command| Command::new_parametrized(None, cleanup_command, parameters));115116 let error_output = "The cleanup command terminated with a non-zero exit code. \117 Append ' || true' to the command if you are sure that this can be ignored.";118119 Ok(commandMerge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
lines 120–127why, one step back120 .map(|cmd| {121 self.run_intermediate_command(122 &cmd,123 error_output,124 output_policy,125 BenchmarkIteration::NonBenchmarkRun,126 )127 })Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 128–132why, one step back128 .transpose()?129 .unwrap_or_default())130 }131132 /// Run the command specified by `--prepare`.Multiple output policiesDavid Peterbefore adoption99d24b7
lines 133–136why, one step back133 fn run_preparation_command(134 &self,135 command: &Command<'_>,136 output_policy: &CommandOutputPolicy,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 137why, one step back137 iteration: executor::BenchmarkIteration,Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 138why, one step back138 ) -> Result<Measurement> {Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 139–141why, one step back139 let error_output = "The preparation command terminated with a non-zero exit code. \140 Append ' || true' to the command if you are sure that this can be ignored.";141Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 142why, one step back142 self.run_intermediate_command(command, error_output, output_policy, iteration)Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 143–144why, one step back143 }144Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
line 145why, one step back145 /// Run the command specified by `--conclude`.Multiple output policiesDavid Peterbefore adoption99d24b7
lines 146–149why, one step back146 fn run_conclusion_command(147 &self,148 command: &Command<'_>,149 output_policy: &CommandOutputPolicy,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 150why, one step back150 iteration: executor::BenchmarkIteration,Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 151why, one step back151 ) -> Result<Measurement> {Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 152–154why, one step back152 let error_output = "The conclusion command terminated with a non-zero exit code. \153 Append ' || true' to the command if you are sure that this can be ignored.";154Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 155why, one step back155 self.run_intermediate_command(command, error_output, output_policy, iteration)Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 156–157why, one step back156 }157Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 158–160why, one step back158 fn validate_measurement(&self, measurement: &Measurement) -> Result<()> {159 if self.options.skip_unavailable_metrics {160 return Ok(());Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
line 161why, one step back161 }Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 162–168why, one step back162 for selection in &self.options.metrics {163 ensure!(selection.metric.value(measurement).is_some(),164 "Metric '{}' is unavailable for '{}'. Check platform support and hardware-counter permissions.",165 selection.metric.name(), self.command.get_command_line());166 }167 Ok(())168 }Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
line 169why, one step back169Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 170–171why, one step back170 /// Run the benchmark for a single command171 pub fn run(&self, reference: Option<&BenchmarkResult>) -> Result<BenchmarkResult> {Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
line 172why, one step back172 let mut measurements = Measurements::default();Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
line 173why, one step back173Multiple output policiesDavid Peterbefore adoption99d24b7
lines 174–175why, one step back174 let output_policy = &self.options.command_output_policies[self.number];175Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 176–187why, one step back176 let preparation_command = self.options.preparation_command.as_ref().map(|values| {177 let preparation_command = if values.len() == 1 {178 &values[0]179 } else {180 &values[self.number]181 };182 Command::new_parametrized(183 None,184 preparation_command,185 self.command.get_parameters().iter().cloned(),186 )187 });Multiple output policiesDavid Peterbefore adoption99d24b7
line 188why, one step back188Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 189why, one step back189 let run_preparation_command = |iteration: executor::BenchmarkIteration| {Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 190–191why, one step back190 preparation_command191 .as_ref()Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 192why, one step back192 .map(|cmd| self.run_preparation_command(cmd, output_policy, iteration))Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 193–195why, one step back193 .transpose()194 };195Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 196–207why, one step back196 let conclusion_command = self.options.conclusion_command.as_ref().map(|values| {197 let conclusion_command = if values.len() == 1 {198 &values[0]199 } else {200 &values[self.number]201 };202 Command::new_parametrized(203 None,204 conclusion_command,205 self.command.get_parameters().iter().cloned(),206 )207 });Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 208why, one step back208 let run_conclusion_command = |iteration: executor::BenchmarkIteration| {Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 209–210why, one step back209 conclusion_command210 .as_ref()Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 211why, one step back211 .map(|cmd| self.run_conclusion_command(cmd, output_policy, iteration))Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 212–214why, one step back212 .transpose()213 };214Multiple output policiesDavid Peterbefore adoption99d24b7
line 215why, one step back215 self.run_setup_command(self.command.get_parameters().iter().cloned(), output_policy)?;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
line 216why, one step back216Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 217–225why, one step back217 let progress_header = format!(218 "{}: {}",219 format!("Benchmark {}", self.number + 1).bold(),220 self.command221 .get_name_with_unused_parameters()222 .white()223 .bold()224 );225Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 226–237why, one step back226 // Warmup phase227 if self.options.warmup_count > 0 {228 let progress_bar = if self.options.output_style != OutputStyleOption::Disabled {229 Some(get_progress_bar(230 self.options.warmup_count,231 "Performing warmup runs",232 self.options.output_style,233 ))234 } else {235 None236 };237Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 238–241why, one step back238 if let Some(bar) = &progress_bar {239 set_benchmark_header(bar, progress_header.clone());240 }241Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 242why, one step back242 for i in 0..self.options.warmup_count {Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
lines 243–244why, one step back243 let warmup_iteration = BenchmarkIteration::Warmup(i);244 let _ = run_preparation_command(warmup_iteration)?;Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
lines 245–246why, one step back245 let _ = self.executor.run_command_and_measure(246 self.command,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 247why, one step back247 warmup_iteration,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 248why, one step back248 None,Multiple output policiesDavid Peterbefore adoption99d24b7
line 249why, one step back249 output_policy,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 250why, one step back250 )?;Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 251why, one step back251 let _ = run_conclusion_command(warmup_iteration)?;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 252–264why, one step back252 if let Some(bar) = progress_bar.as_ref() {253 bar.inc(1)254 }255 }256 if let Some(bar) = progress_bar.as_ref() {257 bar.finish_and_clear()258 }259 }260261 // Set up progress bar (and spinner for initial measurement)262 let progress_bar = if self.options.output_style != OutputStyleOption::Disabled {263 Some(get_progress_bar(264 self.options.run_bounds.min,Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
lines 265–269why, one step back265 if preparation_command.is_some() {266 "Running preparation command"267 } else {268 "Initial run"269 },Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 270–275why, one step back270 self.options.output_style,271 ))272 } else {273 None274 };275Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 276–279why, one step back276 if let Some(bar) = &progress_bar {277 set_benchmark_header(bar, progress_header);278 }279Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
lines 280–281why, one step back280 let benchmark_iteration = BenchmarkIteration::Benchmark(0);281 let preparation_result = run_preparation_command(benchmark_iteration)?;Merge pull request #961 from sharkdp/codex/uom-quantitiesDavid Peterbefore adoption975a25c
line 282why, one step back282 let preparation_overhead = preparation_result.map_or(Time::zero(), |res| {Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
lines 283–284why, one step back283 res.time_wall_clock + self.executor.time_overhead()284 });Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 285–286why, one step back285286 // Initial timing runMerge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
lines 287–289why, one step back287 if let Some(bar) = progress_bar.as_ref() {288 start_initial_measurement(bar, Instant::now());289 }Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 290why, one step back290 let measurement = self.executor.run_command_and_measure(Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 291why, one step back291 self.command,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 292why, one step back292 benchmark_iteration,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 293why, one step back293 None,Multiple output policiesDavid Peterbefore adoption99d24b7
line 294why, one step back294 output_policy,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 295why, one step back295 )?;Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 296–297why, one step back296 self.validate_measurement(&measurement)?;297 let mut all_succeeded = measurement.exit_status.success();Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
line 298why, one step back298Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
line 299why, one step back299 if let Some(bar) = progress_bar.as_ref() {Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 300–303why, one step back300 let primary = self.options.metrics[0];301 let value = primary.metric.value(&measurement).unwrap();302 let estimate = primary.display_unit(value).format(value);303 finish_initial_measurement(bar, format!("Current estimate: {}", estimate.green()));Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
lines 304–305why, one step back304 }305Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 306why, one step back306 let conclusion_result = run_conclusion_command(benchmark_iteration)?;Merge pull request #961 from sharkdp/codex/uom-quantitiesDavid Peterbefore adoption975a25c
line 307why, one step back307 let conclusion_overhead = conclusion_result.map_or(Time::zero(), |res| {Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
lines 308–309why, one step back308 res.time_wall_clock + self.executor.time_overhead()309 });Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
line 310why, one step back310Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 311–312why, one step back311 // Determine number of benchmark runs312 let runs_in_min_time = (self.options.min_benchmarking_timeMerge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 313why, one step back313 / (measurement.time_wall_clockAdd --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 314–315why, one step back314 + self.executor.time_overhead()315 + preparation_overheadMerge pull request #961 from sharkdp/codex/uom-quantitiesDavid Peterbefore adoption975a25c
line 316why, one step back316 + conclusion_overhead))Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 317why, one step back317 .get::<quantity::ratio>() as u64;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 318–332why, one step back318319 let count = {320 let min = cmp::max(runs_in_min_time, self.options.run_bounds.min);321322 self.options323 .run_bounds324 .max325 .as_ref()326 .map(|max| cmp::min(min, *max))327 .unwrap_or(min)328 };329330 let count_remaining = count - 1;331332 // Save the first resultAlternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 333–334why, one step back333 let primary = self.options.metrics[0];334 let mut primary_total = primary.metric.value(&measurement).unwrap();Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 335why, one step back335 measurements.push(measurement);Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 336–338why, one step back336337 // Re-configure the progress bar338 if let Some(bar) = progress_bar.as_ref() {Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
lines 339–340why, one step back339 bar.set_length(count);340 bar.inc(1);Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 341–343why, one step back341 }342343 // Gather statistics (perform the actual benchmark)Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 344why, one step back344 for i in 0..count_remaining {Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 345why, one step back345 let benchmark_iteration = BenchmarkIteration::Benchmark(i + 1);Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 346–347why, one step back346347 if let Some(bar) = progress_bar.as_ref() {Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 348–352why, one step back348 let mean = primary_total / measurements.len() as f64;349 bar.set_message(format!(350 "Current estimate: {}",351 primary.display_unit(mean).format(mean).green()352 ));Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
line 353why, one step back353 }Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
lines 354–355why, one step back354355 run_preparation_command(benchmark_iteration)?;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
line 356why, one step back356Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 357why, one step back357 let measurement = self.executor.run_command_and_measure(Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 358why, one step back358 self.command,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 359why, one step back359 benchmark_iteration,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 360why, one step back360 None,Multiple output policiesDavid Peterbefore adoption99d24b7
line 361why, one step back361 output_policy,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 362why, one step back362 )?;Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
line 363why, one step back363 self.validate_measurement(&measurement)?;Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 364why, one step back364 let success = measurement.exit_status.success();Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
line 365why, one step back365 primary_total += primary.metric.value(&measurement).unwrap();Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 366why, one step back366 measurements.push(measurement);Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 367–372why, one step back367368 all_succeeded = all_succeeded && success;369370 if let Some(bar) = progress_bar.as_ref() {371 bar.inc(1)372 }Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
line 373why, one step back373Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 374why, one step back374 run_conclusion_command(benchmark_iteration)?;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 375–381why, one step back375 }376377 if let Some(bar) = progress_bar.as_ref() {378 bar.finish_and_clear()379 }380381 if self.options.output_style != OutputStyleOption::Disabled {Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 382–389why, one step back382 report::print(383 self.number,384 &self.command.get_name_with_unused_parameters(),385 &measurements,386 &self.options.metrics,387 self.options.skip_unavailable_metrics,388 reference,389 )?;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 390–395why, one step back390 }391392 // Warnings393 let mut warnings = vec![];394395 // Check execution timeAlternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 396–401why, one step back396 if self397 .options398 .metrics399 .iter()400 .any(|m| m.metric == crate::metric::Metric::TimeWallClock)401 && matches!(self.options.executor_kind, ExecutorKind::Shell(_))Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
lines 402–404why, one step back402 && measurements403 .wall_clock_times()404 .any(|t| t < MIN_EXECUTION_TIME)Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 405–414why, one step back405 {406 warnings.push(Warnings::FastExecutionTime);407 }408409 // Check program exit codes410 if !all_succeeded {411 warnings.push(Warnings::NonZeroExitCode);412 }413414 // Run outlier detectionAlternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
line 415why, one step back415 let scores = measurements.modified_zscores(primary.metric);Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 416–428why, one step back416417 let outlier_warning_options = OutlierWarningOptions {418 warmup_in_use: self.options.warmup_count > 0,419 prepare_in_use: self420 .options421 .preparation_command422 .as_ref()423 .map(|v| v.len())424 .unwrap_or(0)425 > 0,426 };427428 if scores[0] > OUTLIER_THRESHOLD {Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 429–431why, one step back429 warnings.push(Warnings::InitialRunOutlier(430 primary,431 primary.metric.value(&measurements.measurements[0]).unwrap(),Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 432–436why, one step back432 outlier_warning_options,433 ));434 }435436 if !warnings.is_empty() {Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
lines 437–438why, one step back437 let mut stderr = io::stderr().lock();438 console_writeln!(stderr, " ")?;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 439–440why, one step back439440 for warning in &warnings {Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 441why, one step back441 console_writeln!(stderr, " {}: {}", "Warning".yellow(), warning)?;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 442–445why, one step back442 }443 }444445 if self.options.output_style != OutputStyleOption::Disabled {Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 446why, one step back446 console_writeln!(io::stdout(), " ")?;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 447–448why, one step back447 }448Multiple output policiesDavid Peterbefore adoption99d24b7
line 449why, one step back449 self.run_cleanup_command(self.command.get_parameters().iter().cloned(), output_policy)?;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
line 450why, one step back450Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
lines 451–454why, one step back451 let command = self.command.get_command_line();452 let name = self.command.get_name();453 let name = (name != command).then_some(name);454Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
line 455why, one step back455 Ok(BenchmarkResult {Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
lines 456–458why, one step back456 command,457 name,458 display_name: self.command.get_name_with_unused_parameters(),Merge pull request #969 from sharkdp/codex/result-measurementsDavid Peterbefore adoptione689520
line 459why, one step back459 measurements,Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 460–463why, one step back460 parameters: self461 .command462 .get_parameters()463 .iter()Merge pull request #968 from sharkdp/codex/parameter-metadataDavid Peterbefore adoption05de077
lines 464–471why, one step back464 .map(|(name, value)| {465 (466 name.to_string(),467 Parameter {468 value: value.to_string(),469 },470 )471 })Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 472–475why, one step back472 .collect(),473 })474 }475}