mod.rs
This file
Path
src/benchmark/mod.rs
469 lines · 15.5 KiB · Rust
Last changed by
Add --env for benchmark environment overridesDavid Peterbefore adoption6dddb02
History of this fileTake it
The walk stopped after 200 commits: lines older than 0f91d0c point at it.
Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
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 serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
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 serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
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 serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
line 13why, one step back13use crate::command::Command;Run setup/cleanup commands in a shell (#990)David Peterbefore adoption4a9e066
line 14why, one step back14use crate::options::{CommandOutputPolicy, ExecutorKind, Options, OutputStyleOption};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;Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
line 17why, one step back17use crate::output::progress_bar::{Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
line 18why, one step back18 finish_initial_measurement, get_progress_bar, set_benchmark_header, start_initial_measurement,Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
line 19why, one step back19};Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
line 20why, one step back20use crate::output::report;Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 21–22why, one step back21use crate::output::warnings::{OutlierWarningOptions, Warnings};22use crate::parameter::ParameterNameAndValue;Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
line 23why, one step back23use crate::quantity::{self, const_time_from_seconds, Time, Zero};Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 24why, one step back24use benchmark_result::BenchmarkResult;Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
line 25why, one step back25Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
line 26why, one step back26use anyhow::{anyhow, ensure, Result};Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 27–31why, one step back27use colored::*;2829use self::executor::Executor;3031/// Threshold for warning about fast execution timeMerge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 32why, one step back32pub const MIN_EXECUTION_TIME: Time = const_time_from_seconds(0.005);Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 33–55why, one step back3334pub struct Benchmark<'a> {35 number: usize,36 command: &'a Command<'a>,37 options: &'a Options,38 executor: &'a dyn Executor,39}4041impl<'a> Benchmark<'a> {42 pub fn new(43 number: usize,44 command: &'a Command<'a>,45 options: &'a Options,46 executor: &'a dyn Executor,47 ) -> Self {48 Benchmark {49 number,50 command,51 options,52 executor,53 }54 }55Run setup/cleanup commands in a shell (#990)David Peterbefore adoption4a9e066
line 56why, one step back56 /// Run setup, cleanup, preparation, or conclusion commandsBump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 57–59why, one step back57 fn run_intermediate_command(58 &self,59 command: &Command<'_>,Run setup/cleanup commands in a shell (#990)David Peterbefore adoption4a9e066
line 60why, one step back60 kind: &'static str,Multiple output policiesDavid Peterbefore adoption99d24b7
line 61why, one step back61 output_policy: &CommandOutputPolicy,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 62why, one step back62 iteration: executor::BenchmarkIteration,Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 63why, one step back63 ) -> Result<Measurement> {Add --env for benchmark environment overridesDavid Peterbefore adoption6dddb02
line 64why, one step back64 let command = command.clone().with_environment_from(self.command);Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
line 65why, one step back65 self.executorAdd --env for benchmark environment overridesDavid Peterbefore adoption6dddb02
line 66why, one step back66 .run_intermediate_command_and_measure(&command, iteration, output_policy)Run setup/cleanup commands in a shell (#990)David Peterbefore adoption4a9e066
lines 67–74why, one step back67 .map_err(|error| {68 let hint = if cfg!(windows) {69 "Append ' || exit /b 0' to the command if this failure can be ignored."70 } else {71 "Append ' || true' to the command if this failure can be ignored."72 };73 anyhow!("The {kind} command failed: {error:#} {hint}")74 })Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 75–80why, one step back75 }7677 /// Run the command specified by `--setup`.78 fn run_setup_command(79 &self,80 parameters: impl IntoIterator<Item = ParameterNameAndValue<'a>>,Multiple output policiesDavid Peterbefore adoption99d24b7
line 81why, one step back81 output_policy: &CommandOutputPolicy,Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 82why, one step back82 ) -> Result<Measurement> {Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 83–89why, one step back83 let command = self84 .options85 .setup_command86 .as_ref()87 .map(|setup_command| Command::new_parametrized(None, setup_command, parameters));8889 Ok(commandMerge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
lines 90–92why, one step back90 .map(|cmd| {91 self.run_intermediate_command(92 &cmd,Run setup/cleanup commands in a shell (#990)David Peterbefore adoption4a9e066
line 93why, one step back93 "setup",Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
lines 94–97why, one step back94 output_policy,95 BenchmarkIteration::NonBenchmarkRun,96 )97 })Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 98–105why, one step back98 .transpose()?99 .unwrap_or_default())100 }101102 /// Run the command specified by `--cleanup`.103 fn run_cleanup_command(104 &self,105 parameters: impl IntoIterator<Item = ParameterNameAndValue<'a>>,Multiple output policiesDavid Peterbefore adoption99d24b7
line 106why, one step back106 output_policy: &CommandOutputPolicy,Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 107why, one step back107 ) -> Result<Measurement> {Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 108–114why, one step back108 let command = self109 .options110 .cleanup_command111 .as_ref()112 .map(|cleanup_command| Command::new_parametrized(None, cleanup_command, parameters));113114 Ok(commandMerge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
lines 115–117why, one step back115 .map(|cmd| {116 self.run_intermediate_command(117 &cmd,Run setup/cleanup commands in a shell (#990)David Peterbefore adoption4a9e066
line 118why, one step back118 "cleanup",Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
lines 119–122why, one step back119 output_policy,120 BenchmarkIteration::NonBenchmarkRun,121 )122 })Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 123–127why, one step back123 .transpose()?124 .unwrap_or_default())125 }126127 /// Run the command specified by `--prepare`.Multiple output policiesDavid Peterbefore adoption99d24b7
lines 128–131why, one step back128 fn run_preparation_command(129 &self,130 command: &Command<'_>,131 output_policy: &CommandOutputPolicy,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 132why, one step back132 iteration: executor::BenchmarkIteration,Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 133why, one step back133 ) -> Result<Measurement> {Run setup/cleanup commands in a shell (#990)David Peterbefore adoption4a9e066
line 134why, one step back134 self.run_intermediate_command(command, "preparation", output_policy, iteration)Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 135–136why, one step back135 }136Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
line 137why, one step back137 /// Run the command specified by `--conclude`.Multiple output policiesDavid Peterbefore adoption99d24b7
lines 138–141why, one step back138 fn run_conclusion_command(139 &self,140 command: &Command<'_>,141 output_policy: &CommandOutputPolicy,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 142why, one step back142 iteration: executor::BenchmarkIteration,Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11
line 143why, one step back143 ) -> Result<Measurement> {Run setup/cleanup commands in a shell (#990)David Peterbefore adoption4a9e066
line 144why, one step back144 self.run_intermediate_command(command, "conclusion", output_policy, iteration)Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 145–146why, one step back145 }146Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 147–149why, one step back147 fn validate_measurement(&self, measurement: &Measurement) -> Result<()> {148 if self.options.skip_unavailable_metrics {149 return Ok(());Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
line 150why, one step back150 }Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 151–157why, one step back151 for selection in &self.options.metrics {152 ensure!(selection.metric.value(measurement).is_some(),153 "Metric '{}' is unavailable for '{}'. Check platform support and hardware-counter permissions.",154 selection.metric.name(), self.command.get_command_line());155 }156 Ok(())157 }Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
line 158why, one step back158Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 159–160why, one step back159 /// Run the benchmark for a single command160 pub fn run(&self, reference: Option<&BenchmarkResult>) -> Result<BenchmarkResult> {Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
line 161why, one step back161 let mut measurements = Measurements::default();Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
line 162why, one step back162Multiple output policiesDavid Peterbefore adoption99d24b7
lines 163–164why, one step back163 let output_policy = &self.options.command_output_policies[self.number];164Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 165–176why, one step back165 let preparation_command = self.options.preparation_command.as_ref().map(|values| {166 let preparation_command = if values.len() == 1 {167 &values[0]168 } else {169 &values[self.number]170 };171 Command::new_parametrized(172 None,173 preparation_command,174 self.command.get_parameters().iter().cloned(),175 )176 });Multiple output policiesDavid Peterbefore adoption99d24b7
line 177why, one step back177Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 178why, one step back178 let run_preparation_command = |iteration: executor::BenchmarkIteration| {Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 179–180why, one step back179 preparation_command180 .as_ref()Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 181why, one step back181 .map(|cmd| self.run_preparation_command(cmd, output_policy, iteration))Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 182–184why, one step back182 .transpose()183 };184Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 185–196why, one step back185 let conclusion_command = self.options.conclusion_command.as_ref().map(|values| {186 let conclusion_command = if values.len() == 1 {187 &values[0]188 } else {189 &values[self.number]190 };191 Command::new_parametrized(192 None,193 conclusion_command,194 self.command.get_parameters().iter().cloned(),195 )196 });Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 197why, one step back197 let run_conclusion_command = |iteration: executor::BenchmarkIteration| {Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 198–199why, one step back198 conclusion_command199 .as_ref()Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 200why, one step back200 .map(|cmd| self.run_conclusion_command(cmd, output_policy, iteration))Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 201–203why, one step back201 .transpose()202 };203Multiple output policiesDavid Peterbefore adoption99d24b7
line 204why, one step back204 self.run_setup_command(self.command.get_parameters().iter().cloned(), output_policy)?;Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
line 205why, one step back205Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 206–214why, one step back206 let progress_header = format!(207 "{}: {}",208 format!("Benchmark {}", self.number + 1).bold(),209 self.command210 .get_name_with_unused_parameters()211 .white()212 .bold()213 );214Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 215–226why, one step back215 // Warmup phase216 if self.options.warmup_count > 0 {217 let progress_bar = if self.options.output_style != OutputStyleOption::Disabled {218 Some(get_progress_bar(219 self.options.warmup_count,220 "Performing warmup runs",221 self.options.output_style,222 ))223 } else {224 None225 };226Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 227–230why, one step back227 if let Some(bar) = &progress_bar {228 set_benchmark_header(bar, progress_header.clone());229 }230Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 231why, one step back231 for i in 0..self.options.warmup_count {Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
lines 232–233why, one step back232 let warmup_iteration = BenchmarkIteration::Warmup(i);233 let _ = run_preparation_command(warmup_iteration)?;Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
lines 234–235why, one step back234 let _ = self.executor.run_command_and_measure(235 self.command,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 236why, one step back236 warmup_iteration,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 237why, one step back237 None,Multiple output policiesDavid Peterbefore adoption99d24b7
line 238why, one step back238 output_policy,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 239why, one step back239 )?;Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 240why, one step back240 let _ = run_conclusion_command(warmup_iteration)?;Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 241–253why, one step back241 if let Some(bar) = progress_bar.as_ref() {242 bar.inc(1)243 }244 }245 if let Some(bar) = progress_bar.as_ref() {246 bar.finish_and_clear()247 }248 }249250 // Set up progress bar (and spinner for initial measurement)251 let progress_bar = if self.options.output_style != OutputStyleOption::Disabled {252 Some(get_progress_bar(253 self.options.run_bounds.min,Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
lines 254–258why, one step back254 if preparation_command.is_some() {255 "Running preparation command"256 } else {257 "Initial run"258 },Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 259–264why, one step back259 self.options.output_style,260 ))261 } else {262 None263 };264Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 265–268why, one step back265 if let Some(bar) = &progress_bar {266 set_benchmark_header(bar, progress_header);267 }268Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
lines 269–270why, one step back269 let benchmark_iteration = BenchmarkIteration::Benchmark(0);270 let preparation_result = run_preparation_command(benchmark_iteration)?;Merge pull request #961 from sharkdp/codex/uom-quantitiesDavid Peterbefore adoption975a25c
line 271why, one step back271 let preparation_overhead = preparation_result.map_or(Time::zero(), |res| {Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
lines 272–273why, one step back272 res.time_wall_clock + self.executor.time_overhead()273 });Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 274–275why, one step back274275 // Initial timing runMerge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
lines 276–278why, one step back276 if let Some(bar) = progress_bar.as_ref() {277 start_initial_measurement(bar, Instant::now());278 }Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 279why, one step back279 let measurement = self.executor.run_command_and_measure(Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 280why, one step back280 self.command,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 281why, one step back281 benchmark_iteration,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 282why, one step back282 None,Multiple output policiesDavid Peterbefore adoption99d24b7
line 283why, one step back283 output_policy,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 284why, one step back284 )?;Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 285–286why, one step back285 self.validate_measurement(&measurement)?;286 let mut all_succeeded = measurement.exit_status.success();Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
line 287why, one step back287Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
line 288why, one step back288 if let Some(bar) = progress_bar.as_ref() {Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 289–292why, one step back289 let primary = self.options.metrics[0];290 let value = primary.metric.value(&measurement).unwrap();291 let estimate = primary.display_unit(value).format(value);292 finish_initial_measurement(bar, format!("Current estimate: {}", estimate.green()));Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
lines 293–294why, one step back293 }294Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 295why, one step back295 let conclusion_result = run_conclusion_command(benchmark_iteration)?;Merge pull request #961 from sharkdp/codex/uom-quantitiesDavid Peterbefore adoption975a25c
line 296why, one step back296 let conclusion_overhead = conclusion_result.map_or(Time::zero(), |res| {Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
lines 297–298why, one step back297 res.time_wall_clock + self.executor.time_overhead()298 });Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
line 299why, one step back299Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 300–301why, one step back300 // Determine number of benchmark runs301 let runs_in_min_time = (self.options.min_benchmarking_timeMerge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 302why, one step back302 / (measurement.time_wall_clockAdd --conclude option with testsJack O'Connorbefore adoptione13d0cb
lines 303–304why, one step back303 + self.executor.time_overhead()304 + preparation_overheadMerge pull request #961 from sharkdp/codex/uom-quantitiesDavid Peterbefore adoption975a25c
line 305why, one step back305 + conclusion_overhead))Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 306why, one step back306 .get::<quantity::ratio>() as u64;Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 307–321why, one step back307308 let count = {309 let min = cmp::max(runs_in_min_time, self.options.run_bounds.min);310311 self.options312 .run_bounds313 .max314 .as_ref()315 .map(|max| cmp::min(min, *max))316 .unwrap_or(min)317 };318319 let count_remaining = count - 1;320321 // Save the first resultAlternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 322–323why, one step back322 let primary = self.options.metrics[0];323 let mut primary_total = primary.metric.value(&measurement).unwrap();Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 324why, one step back324 measurements.push(measurement);Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 325–327why, one step back325326 // Re-configure the progress bar327 if let Some(bar) = progress_bar.as_ref() {Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
lines 328–329why, one step back328 bar.set_length(count);329 bar.inc(1);Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 330–332why, one step back330 }331332 // Gather statistics (perform the actual benchmark)Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 333why, one step back333 for i in 0..count_remaining {Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 334why, one step back334 let benchmark_iteration = BenchmarkIteration::Benchmark(i + 1);Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 335–336why, one step back335336 if let Some(bar) = progress_bar.as_ref() {Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 337–341why, one step back337 let mean = primary_total / measurements.len() as f64;338 bar.set_message(format!(339 "Current estimate: {}",340 primary.display_unit(mean).format(mean).green()341 ));Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
line 342why, one step back342 }Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6
lines 343–344why, one step back343344 run_preparation_command(benchmark_iteration)?;Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
line 345why, one step back345Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 346why, one step back346 let measurement = self.executor.run_command_and_measure(Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 347why, one step back347 self.command,Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 348why, one step back348 benchmark_iteration,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 349why, one step back349 None,Multiple output policiesDavid Peterbefore adoption99d24b7
line 350why, one step back350 output_policy,Add iteration information to failure error messageDavid Peterbefore adoption83f04cd
line 351why, one step back351 )?;Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
line 352why, one step back352 self.validate_measurement(&measurement)?;Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 353why, one step back353 let success = measurement.exit_status.success();Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
line 354why, one step back354 primary_total += primary.metric.value(&measurement).unwrap();Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 355why, one step back355 measurements.push(measurement);Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 356–361why, one step back356357 all_succeeded = all_succeeded && success;358359 if let Some(bar) = progress_bar.as_ref() {360 bar.inc(1)361 }Add --conclude option with testsJack O'Connorbefore adoptione13d0cb
line 362why, one step back362Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61
line 363why, one step back363 run_conclusion_command(benchmark_iteration)?;Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 364–370why, one step back364 }365366 if let Some(bar) = progress_bar.as_ref() {367 bar.finish_and_clear()368 }369370 if self.options.output_style != OutputStyleOption::Disabled {Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 371–378why, one step back371 report::print(372 self.number,373 &self.command.get_name_with_unused_parameters(),374 &measurements,375 &self.options.metrics,376 self.options.skip_unavailable_metrics,377 reference,378 )?;Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 379–384why, one step back379 }380381 // Warnings382 let mut warnings = vec![];383384 // Check execution timeAlternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 385–390why, one step back385 if self386 .options387 .metrics388 .iter()389 .any(|m| m.metric == crate::metric::Metric::TimeWallClock)390 && matches!(self.options.executor_kind, ExecutorKind::Shell(_))Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1
lines 391–393why, one step back391 && measurements392 .wall_clock_times()393 .any(|t| t < MIN_EXECUTION_TIME)Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 394–403why, one step back394 {395 warnings.push(Warnings::FastExecutionTime);396 }397398 // Check program exit codes399 if !all_succeeded {400 warnings.push(Warnings::NonZeroExitCode);401 }402403 // Run outlier detectionAlternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
line 404why, one step back404 let scores = measurements.modified_zscores(primary.metric);Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 405–417why, one step back405406 let outlier_warning_options = OutlierWarningOptions {407 warmup_in_use: self.options.warmup_count > 0,408 prepare_in_use: self409 .options410 .preparation_command411 .as_ref()412 .map(|v| v.len())413 .unwrap_or(0)414 > 0,415 };416417 if scores[0] > OUTLIER_THRESHOLD {Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
lines 418–420why, one step back418 warnings.push(Warnings::InitialRunOutlier(419 primary,420 primary.metric.value(&measurements.measurements[0]).unwrap(),Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 421–425why, one step back421 outlier_warning_options,422 ));423 }424425 if !warnings.is_empty() {Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
lines 426–427why, one step back426 let mut stderr = io::stderr().lock();427 console_writeln!(stderr, " ")?;Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 428–429why, one step back428429 for warning in &warnings {Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 430why, one step back430 console_writeln!(stderr, " {}: {}", "Warning".yellow(), warning)?;Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 431–434why, one step back431 }432 }433434 if self.options.output_style != OutputStyleOption::Disabled {Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 435why, one step back435 console_writeln!(io::stdout(), " ")?;Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 436–437why, one step back436 }437Multiple output policiesDavid Peterbefore adoption99d24b7
line 438why, one step back438 self.run_cleanup_command(self.command.get_parameters().iter().cloned(), output_policy)?;Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
line 439why, one step back439Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
lines 440–443why, one step back440 let command = self.command.get_command_line();441 let name = self.command.get_name();442 let name = (name != command).then_some(name);443Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
line 444why, one step back444 Ok(BenchmarkResult {Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
lines 445–446why, one step back445 command,446 name,Add --env for benchmark environment overridesDavid Peterbefore adoption6dddb02
lines 447–451why, one step back447 environment: self448 .command449 .get_environment()450 .map(|(name, value)| (name.to_owned(), value))451 .collect(),Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015
line 452why, one step back452 display_name: self.command.get_name_with_unused_parameters(),Merge pull request #969 from sharkdp/codex/result-measurementsDavid Peterbefore adoptione689520
line 453why, one step back453 measurements,Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 454–457why, one step back454 parameters: self455 .command456 .get_parameters()457 .iter()Merge pull request #968 from sharkdp/codex/parameter-metadataDavid Peterbefore adoption05de077
lines 458–465why, one step back458 .map(|(name, value)| {459 (460 name.to_string(),461 Parameter {462 value: value.to_string(),463 },464 )465 })Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c
lines 466–469why, one step back466 .collect(),467 })468 }469}