Skip to content
Myr

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 file

Take 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 back
1pub mod benchmark_result;
2pub mod executor;

Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11

line 3why, one step back
3pub mod measurement;

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 4–6why, one step back
4pub mod scheduler;
56use std::cmp;

Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834

line 7why, one step back
7use std::io::{self, Write};

Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6

line 8why, one step back
8use std::time::Instant;

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

line 9why, one step back
9

Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015

line 10why, one step back
10use crate::benchmark::benchmark_result::Parameter;

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 11why, one step back
11use crate::benchmark::executor::BenchmarkIteration;

Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015

line 12why, one step back
12use crate::benchmark::measurement::{Measurement, Measurements};

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

line 13why, one step back
13use crate::command::Command;

Run setup/cleanup commands in a shell (#990)David Peterbefore adoption4a9e066

line 14why, one step back
14use crate::options::{CommandOutputPolicy, ExecutorKind, Options, OutputStyleOption};

Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1

line 15why, one step back
15use crate::outlier_detection::OUTLIER_THRESHOLD;

Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834

line 16why, one step back
16use crate::output::console_writeln;

Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6

line 17why, one step back
17use crate::output::progress_bar::{

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 18why, one step back
18 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 back
19};

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 20why, one step back
20use crate::output::report;

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 21–22why, one step back
21use crate::output::warnings::{OutlierWarningOptions, Warnings};
22use crate::parameter::ParameterNameAndValue;

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 23why, one step back
23use crate::quantity::{self, const_time_from_seconds, Time, Zero};

Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015

line 24why, one step back
24use benchmark_result::BenchmarkResult;

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

line 25why, one step back
25

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 26why, one step back
26use anyhow::{anyhow, ensure, Result};

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 27–31why, one step back
27use colored::*;
2829use self::executor::Executor;3031/// Threshold for warning about fast execution time

Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015

line 32why, one step back
32pub 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 back
33
34pub 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 }55

Run setup/cleanup commands in a shell (#990)David Peterbefore adoption4a9e066

line 56why, one step back
56 /// Run setup, cleanup, preparation, or conclusion commands

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 57–59why, one step back
57 fn run_intermediate_command(
58 &self,59 command: &Command<'_>,

Run setup/cleanup commands in a shell (#990)David Peterbefore adoption4a9e066

line 60why, one step back
60 kind: &'static str,

Multiple output policiesDavid Peterbefore adoption99d24b7

line 61why, one step back
61 output_policy: &CommandOutputPolicy,

Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61

line 62why, one step back
62 iteration: executor::BenchmarkIteration,

Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11

line 63why, one step back
63 ) -> Result<Measurement> {

Add --env for benchmark environment overridesDavid Peterbefore adoption6dddb02

line 64why, one step back
64 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 back
65 self.executor

Add --env for benchmark environment overridesDavid Peterbefore adoption6dddb02

line 66why, one step back
66 .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 back
67 .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 back
75 }
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 back
81 output_policy: &CommandOutputPolicy,

Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11

line 82why, one step back
82 ) -> Result<Measurement> {

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 83–89why, one step back
83 let command = self
84 .options85 .setup_command86 .as_ref()87 .map(|setup_command| Command::new_parametrized(None, setup_command, parameters));8889 Ok(command

Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61

lines 90–92why, one step back
90 .map(|cmd| {
91 self.run_intermediate_command(92 &cmd,

Run setup/cleanup commands in a shell (#990)David Peterbefore adoption4a9e066

line 93why, one step back
93 "setup",

Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61

lines 94–97why, one step back
94 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 back
98 .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 back
106 output_policy: &CommandOutputPolicy,

Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11

line 107why, one step back
107 ) -> Result<Measurement> {

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 108–114why, one step back
108 let command = self
109 .options110 .cleanup_command111 .as_ref()112 .map(|cleanup_command| Command::new_parametrized(None, cleanup_command, parameters));113114 Ok(command

Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61

lines 115–117why, one step back
115 .map(|cmd| {
116 self.run_intermediate_command(117 &cmd,

Run setup/cleanup commands in a shell (#990)David Peterbefore adoption4a9e066

line 118why, one step back
118 "cleanup",

Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61

lines 119–122why, one step back
119 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 back
123 .transpose()?
124 .unwrap_or_default())125 }126127 /// Run the command specified by `--prepare`.

Multiple output policiesDavid Peterbefore adoption99d24b7

lines 128–131why, one step back
128 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 back
132 iteration: executor::BenchmarkIteration,

Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11

line 133why, one step back
133 ) -> Result<Measurement> {

Run setup/cleanup commands in a shell (#990)David Peterbefore adoption4a9e066

line 134why, one step back
134 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 back
135 }
136

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

line 137why, one step back
137 /// Run the command specified by `--conclude`.

Multiple output policiesDavid Peterbefore adoption99d24b7

lines 138–141why, one step back
138 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 back
142 iteration: executor::BenchmarkIteration,

Merge pull request #954 from sharkdp/codex/remove-statisticalDavid Peterbefore adoption750fe11

line 143why, one step back
143 ) -> Result<Measurement> {

Run setup/cleanup commands in a shell (#990)David Peterbefore adoption4a9e066

line 144why, one step back
144 self.run_intermediate_command(command, "conclusion", output_policy, iteration)

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 145–146why, one step back
145 }
146

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 147–149why, one step back
147 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 back
150 }

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 151–157why, one step back
151 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 back
158

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 159–160why, one step back
159 /// Run the benchmark for a single command
160 pub fn run(&self, reference: Option<&BenchmarkResult>) -> Result<BenchmarkResult> {

Merge pull request #958 from sharkdp/codex/measurements-collectionDavid Peterbefore adoption16e23a1

line 161why, one step back
161 let mut measurements = Measurements::default();

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

line 162why, one step back
162

Multiple output policiesDavid Peterbefore adoption99d24b7

lines 163–164why, one step back
163 let output_policy = &self.options.command_output_policies[self.number];
164

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 165–176why, one step back
165 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 back
177

Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61

line 178why, one step back
178 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 back
179 preparation_command
180 .as_ref()

Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61

line 181why, one step back
181 .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 back
182 .transpose()
183 };184

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 185–196why, one step back
185 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 back
197 let run_conclusion_command = |iteration: executor::BenchmarkIteration| {

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 198–199why, one step back
198 conclusion_command
199 .as_ref()

Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61

line 200why, one step back
200 .map(|cmd| self.run_conclusion_command(cmd, output_policy, iteration))

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 201–203why, one step back
201 .transpose()
202 };203

Multiple output policiesDavid Peterbefore adoption99d24b7

line 204why, one step back
204 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 back
205

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 206–214why, one step back
206 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 );214

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 215–226why, one step back
215 // Warmup phase
216 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 };226

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 227–230why, one step back
227 if let Some(bar) = &progress_bar {
228 set_benchmark_header(bar, progress_header.clone());229 }230

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 231why, one step back
231 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 back
232 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 back
234 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 back
236 warmup_iteration,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 237why, one step back
237 None,

Multiple output policiesDavid Peterbefore adoption99d24b7

line 238why, one step back
238 output_policy,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 239why, one step back
239 )?;

Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61

line 240why, one step back
240 let _ = run_conclusion_command(warmup_iteration)?;

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 241–253why, one step back
241 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 back
254 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 back
259 self.options.output_style,
260 ))261 } else {262 None263 };264

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 265–268why, one step back
265 if let Some(bar) = &progress_bar {
266 set_benchmark_header(bar, progress_header);267 }268

Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61

lines 269–270why, one step back
269 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 back
271 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 back
272 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 back
274
275 // Initial timing run

Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6

lines 276–278why, one step back
276 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 back
279 let measurement = self.executor.run_command_and_measure(

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 280why, one step back
280 self.command,

Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61

line 281why, one step back
281 benchmark_iteration,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 282why, one step back
282 None,

Multiple output policiesDavid Peterbefore adoption99d24b7

line 283why, one step back
283 output_policy,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 284why, one step back
284 )?;

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 285–286why, one step back
285 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 back
287

Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6

line 288why, one step back
288 if let Some(bar) = progress_bar.as_ref() {

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 289–292why, one step back
289 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 back
293 }
294

Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61

line 295why, one step back
295 let conclusion_result = run_conclusion_command(benchmark_iteration)?;

Merge pull request #961 from sharkdp/codex/uom-quantitiesDavid Peterbefore adoption975a25c

line 296why, one step back
296 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 back
297 res.time_wall_clock + self.executor.time_overhead()
298 });

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

line 299why, one step back
299

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 300–301why, one step back
300 // Determine number of benchmark runs
301 let runs_in_min_time = (self.options.min_benchmarking_time

Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015

line 302why, one step back
302 / (measurement.time_wall_clock

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 303–304why, one step back
303 + self.executor.time_overhead()
304 + preparation_overhead

Merge pull request #961 from sharkdp/codex/uom-quantitiesDavid Peterbefore adoption975a25c

line 305why, one step back
305 + conclusion_overhead))

Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015

line 306why, one step back
306 .get::<quantity::ratio>() as u64;

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 307–321why, one step back
307
308 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 result

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 322–323why, one step back
322 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 back
324 measurements.push(measurement);

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 325–327why, one step back
325
326 // 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 back
328 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 back
330 }
331332 // Gather statistics (perform the actual benchmark)

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 333why, one step back
333 for i in 0..count_remaining {

Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61

line 334why, one step back
334 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 back
335
336 if let Some(bar) = progress_bar.as_ref() {

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 337–341why, one step back
337 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 back
342 }

Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6

lines 343–344why, one step back
343
344 run_preparation_command(benchmark_iteration)?;

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

line 345why, one step back
345

Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015

line 346why, one step back
346 let measurement = self.executor.run_command_and_measure(

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 347why, one step back
347 self.command,

Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61

line 348why, one step back
348 benchmark_iteration,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 349why, one step back
349 None,

Multiple output policiesDavid Peterbefore adoption99d24b7

line 350why, one step back
350 output_policy,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 351why, one step back
351 )?;

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 352why, one step back
352 self.validate_measurement(&measurement)?;

Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015

line 353why, one step back
353 let success = measurement.exit_status.success();

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 354why, one step back
354 primary_total += primary.metric.value(&measurement).unwrap();

Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015

line 355why, one step back
355 measurements.push(measurement);

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 356–361why, one step back
356
357 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 back
362

Merge pull request #807 from willcl-ark/expose-run-varDavid Peterbefore adoption30a2b61

line 363why, one step back
363 run_conclusion_command(benchmark_iteration)?;

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 364–370why, one step back
364 }
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 back
371 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 back
379 }
380381 // Warnings382 let mut warnings = vec![];383384 // Check execution time

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 385–390why, one step back
385 if self
386 .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 back
391 && measurements
392 .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 back
394 {
395 warnings.push(Warnings::FastExecutionTime);396 }397398 // Check program exit codes399 if !all_succeeded {400 warnings.push(Warnings::NonZeroExitCode);401 }402403 // Run outlier detection

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 404why, one step back
404 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 back
405
406 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 back
418 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 back
421 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 back
426 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 back
428
429 for warning in &warnings {

Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834

line 430why, one step back
430 console_writeln!(stderr, " {}: {}", "Warning".yellow(), warning)?;

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 431–434why, one step back
431 }
432 }433434 if self.options.output_style != OutputStyleOption::Disabled {

Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834

line 435why, one step back
435 console_writeln!(io::stdout(), " ")?;

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 436–437why, one step back
436 }
437

Multiple output policiesDavid Peterbefore adoption99d24b7

line 438why, one step back
438 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 back
439

Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015

lines 440–443why, one step back
440 let command = self.command.get_command_line();
441 let name = self.command.get_name();442 let name = (name != command).then_some(name);443

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

line 444why, one step back
444 Ok(BenchmarkResult {

Merge pull request #790 from sharkdp/new-metricsDavid Peterbefore adoptionf26c015

lines 445–446why, one step back
445 command,
446 name,

Add --env for benchmark environment overridesDavid Peterbefore adoption6dddb02

lines 447–451why, one step back
447 environment: self
448 .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 back
452 display_name: self.command.get_name_with_unused_parameters(),

Merge pull request #969 from sharkdp/codex/result-measurementsDavid Peterbefore adoptione689520

line 453why, one step back
453 measurements,

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 454–457why, one step back
454 parameters: self
455 .command456 .get_parameters()457 .iter()

Merge pull request #968 from sharkdp/codex/parameter-metadataDavid Peterbefore adoption05de077

lines 458–465why, one step back
458 .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 back
466 .collect(),
467 })468 }469}