Skip to content
Myr

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 file

Take 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 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 clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

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 clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

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 clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

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

Multiple output policiesDavid Peterbefore adoption99d24b7

lines 14–16why, one step back
14use crate::options::{
15 CmdFailureAction, CommandOutputPolicy, ExecutorKind, Options, OutputStyleOption,16};

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

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

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

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

Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6

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

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

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

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

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

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

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

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

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

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

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

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

line 27why, one step back
27

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

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

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

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

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

line 34why, one step back
34pub 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 back
35
36pub 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 back
63 output_policy: &CommandOutputPolicy,

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

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

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

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

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

line 66why, one step back
66 self.executor

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

lines 67–68why, one step back
67 .run_command_and_measure(
68 command,

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

line 69why, one step back
69 iteration,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 70why, one step back
70 Some(CmdFailureAction::RaiseError),

Multiple output policiesDavid Peterbefore adoption99d24b7

line 71why, one step back
71 output_policy,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 72why, one step back
72 )

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 73–79why, one step back
73 .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 back
80 output_policy: &CommandOutputPolicy,

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

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

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 82–91why, one step back
82 let command = self
83 .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(command

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

lines 92–99why, one step back
92 .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 back
100 .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 back
108 output_policy: &CommandOutputPolicy,

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

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

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 110–119why, one step back
110 let command = self
111 .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(command

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

lines 120–127why, one step back
120 .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 back
128 .transpose()?
129 .unwrap_or_default())130 }131132 /// Run the command specified by `--prepare`.

Multiple output policiesDavid Peterbefore adoption99d24b7

lines 133–136why, one step back
133 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 back
137 iteration: executor::BenchmarkIteration,

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

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

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 139–141why, one step back
139 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.";141

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

line 142why, one step back
142 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 back
143 }
144

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

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

Multiple output policiesDavid Peterbefore adoption99d24b7

lines 146–149why, one step back
146 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 back
150 iteration: executor::BenchmarkIteration,

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

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

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 152–154why, one step back
152 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.";154

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

line 155why, one step back
155 self.run_intermediate_command(command, error_output, output_policy, iteration)

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 156–157why, one step back
156 }
157

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

lines 158–160why, one step back
158 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 back
161 }

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

lines 162–168why, one step back
162 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 back
169

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

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

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

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

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

line 173why, one step back
173

Multiple output policiesDavid Peterbefore adoption99d24b7

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

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

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

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

line 189why, one step back
189 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 back
190 preparation_command
191 .as_ref()

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

line 192why, one step back
192 .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 back
193 .transpose()
194 };195

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

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

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 209–210why, one step back
209 conclusion_command
210 .as_ref()

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

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

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 212–214why, one step back
212 .transpose()
213 };214

Multiple output policiesDavid Peterbefore adoption99d24b7

line 215why, one step back
215 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 back
216

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

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

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

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

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

lines 238–241why, one step back
238 if let Some(bar) = &progress_bar {
239 set_benchmark_header(bar, progress_header.clone());240 }241

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 242why, one step back
242 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 back
243 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 back
245 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 back
247 warmup_iteration,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 248why, one step back
248 None,

Multiple output policiesDavid Peterbefore adoption99d24b7

line 249why, one step back
249 output_policy,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 250why, one step back
250 )?;

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

line 251why, one step back
251 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 back
252 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 back
265 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 back
270 self.options.output_style,
271 ))272 } else {273 None274 };275

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

lines 276–279why, one step back
276 if let Some(bar) = &progress_bar {
277 set_benchmark_header(bar, progress_header);278 }279

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

lines 280–281why, one step back
280 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 back
282 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 back
283 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 back
285
286 // Initial timing run

Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6

lines 287–289why, one step back
287 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 back
290 let measurement = self.executor.run_command_and_measure(

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

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

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

line 292why, one step back
292 benchmark_iteration,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 293why, one step back
293 None,

Multiple output policiesDavid Peterbefore adoption99d24b7

line 294why, one step back
294 output_policy,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 295why, one step back
295 )?;

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

lines 296–297why, one step back
296 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 back
298

Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6

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

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

lines 300–303why, one step back
300 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 back
304 }
305

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

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

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

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

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

line 310why, one step back
310

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

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

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

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

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 314–315why, one step back
314 + self.executor.time_overhead()
315 + preparation_overhead

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

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

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

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

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 318–332why, one step back
318
319 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 result

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

lines 333–334why, one step back
333 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 back
335 measurements.push(measurement);

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 336–338why, one step back
336
337 // 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 back
339 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 back
341 }
342343 // Gather statistics (perform the actual benchmark)

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

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

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

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

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

lines 348–352why, one step back
348 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 back
353 }

Merge pull request #581 from devonhollowood/elapsedDavid Peterbefore adoption5d501b6

lines 354–355why, one step back
354
355 run_preparation_command(benchmark_iteration)?;

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

line 356why, one step back
356

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

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

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

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

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

line 359why, one step back
359 benchmark_iteration,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 360why, one step back
360 None,

Multiple output policiesDavid Peterbefore adoption99d24b7

line 361why, one step back
361 output_policy,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 362why, one step back
362 )?;

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

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

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

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

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

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

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

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

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 367–372why, one step back
367
368 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 back
373

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

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

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 375–381why, one step back
375 }
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 back
382 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 back
390 }
391392 // Warnings393 let mut warnings = vec![];394395 // Check execution time

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

lines 396–401why, one step back
396 if self
397 .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 back
402 && measurements
403 .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 back
405 {
406 warnings.push(Warnings::FastExecutionTime);407 }408409 // Check program exit codes410 if !all_succeeded {411 warnings.push(Warnings::NonZeroExitCode);412 }413414 // Run outlier detection

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

line 415why, one step back
415 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 back
416
417 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 back
429 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 back
432 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 back
437 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 back
439
440 for warning in &warnings {

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

line 441why, one step back
441 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 back
442 }
443 }444445 if self.options.output_style != OutputStyleOption::Disabled {

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

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

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 447–448why, one step back
447 }
448

Multiple output policiesDavid Peterbefore adoption99d24b7

line 449why, one step back
449 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 back
450

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

lines 451–454why, one step back
451 let command = self.command.get_command_line();
452 let name = self.command.get_name();453 let name = (name != command).then_some(name);454

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

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

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

lines 456–458why, one step back
456 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 back
459 measurements,

Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f

lines 460–463why, one step back
460 parameters: self
461 .command462 .get_parameters()463 .iter()

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

lines 464–471why, one step back
464 .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 back
472 .collect(),
473 })474 }475}