Skip to content
Myr

mod.rs

This file

Path

src/benchmark/mod.rs

483 lines · 16.1 KiB · Rust

Last changed by

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

History of this file

Take it

The walk stopped after 200 commits: lines older than acf156e point at it.

ran cargo fmtHumble Penguinbefore adoptionacf156e

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;

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 4–7why, one step back
4pub mod relative_speed;
5pub mod scheduler;67use std::cmp;

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

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

ran cargo fmtHumble Penguinbefore adoptionacf156e

line 9why, one step back
9

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

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

ran cargo fmtHumble Penguinbefore adoptionacf156e

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

Multiple output policiesDavid Peterbefore adoption99d24b7

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

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;

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 17–19why, one step back
17use crate::output::progress_bar::get_progress_bar;
18use crate::output::warnings::{OutlierWarningOptions, Warnings};19use crate::parameter::ParameterNameAndValue;

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

line 20why, one step back
20use crate::quantity::{const_time_from_seconds, ratio, FormatQuantity, Time, Zero};

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

line 21why, one step back
21use benchmark_result::{BenchmarkResult, Parameter};

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

line 22why, one step back
22use measurement::{Measurement, Measurements};

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 23–29why, one step back
23
24use anyhow::{anyhow, Result};25use colored::*;2627use self::executor::Executor;2829/// Threshold for warning about fast execution time

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

line 30why, one step back
30pub const MIN_EXECUTION_TIME: Time = const_time_from_seconds(5e-3);

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 31–58why, one step back
31
32pub struct Benchmark<'a> {33 number: usize,34 command: &'a Command<'a>,35 options: &'a Options,36 executor: &'a dyn Executor,37}3839impl<'a> Benchmark<'a> {40 pub fn new(41 number: usize,42 command: &'a Command<'a>,43 options: &'a Options,44 executor: &'a dyn Executor,45 ) -> Self {46 Benchmark {47 number,48 command,49 options,50 executor,51 }52 }5354 /// Run setup, cleanup, or preparation commands55 fn run_intermediate_command(56 &self,57 command: &Command<'_>,58 error_output: &'static str,

Multiple output policiesDavid Peterbefore adoption99d24b7

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

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

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

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

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

ran cargo fmtHumble Penguinbefore adoptionacf156e

line 62why, one step back
62 self.executor

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

lines 63–64why, one step back
63 .run_command_and_measure(
64 command,

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

line 65why, one step back
65 iteration,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

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

Multiple output policiesDavid Peterbefore adoption99d24b7

line 67why, one step back
67 output_policy,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 68why, one step back
68 )

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 69–75why, one step back
69 .map_err(|_| anyhow!(error_output))
70 }7172 /// Run the command specified by `--setup`.73 fn run_setup_command(74 &self,75 parameters: impl IntoIterator<Item = ParameterNameAndValue<'a>>,

Multiple output policiesDavid Peterbefore adoption99d24b7

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

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

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

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 78–87why, one step back
78 let command = self
79 .options80 .setup_command81 .as_ref()82 .map(|setup_command| Command::new_parametrized(None, setup_command, parameters));8384 let error_output = "The setup command terminated with a non-zero exit code. \85 Append ' || true' to the command if you are sure that this can be ignored.";8687 Ok(command

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

lines 88–95why, one step back
88 .map(|cmd| {
89 self.run_intermediate_command(90 &cmd,91 error_output,92 output_policy,93 BenchmarkIteration::NonBenchmarkRun,94 )95 })

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 96–103why, one step back
96 .transpose()?
97 .unwrap_or_default())98 }99100 /// Run the command specified by `--cleanup`.101 fn run_cleanup_command(102 &self,103 parameters: impl IntoIterator<Item = ParameterNameAndValue<'a>>,

Multiple output policiesDavid Peterbefore adoption99d24b7

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

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

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

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 106–115why, one step back
106 let command = self
107 .options108 .cleanup_command109 .as_ref()110 .map(|cleanup_command| Command::new_parametrized(None, cleanup_command, parameters));111112 let error_output = "The cleanup command terminated with a non-zero exit code. \113 Append ' || true' to the command if you are sure that this can be ignored.";114115 Ok(command

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

lines 116–123why, one step back
116 .map(|cmd| {
117 self.run_intermediate_command(118 &cmd,119 error_output,120 output_policy,121 BenchmarkIteration::NonBenchmarkRun,122 )123 })

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 124–128why, one step back
124 .transpose()?
125 .unwrap_or_default())126 }127128 /// Run the command specified by `--prepare`.

Multiple output policiesDavid Peterbefore adoption99d24b7

lines 129–132why, one step back
129 fn run_preparation_command(
130 &self,131 command: &Command<'_>,132 output_policy: &CommandOutputPolicy,

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

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

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

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

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 135–137why, one step back
135 let error_output = "The preparation command terminated with a non-zero exit code. \
136 Append ' || true' to the command if you are sure that this can be ignored.";137

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

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

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 139–140why, one step back
139 }
140

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

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

Multiple output policiesDavid Peterbefore adoption99d24b7

lines 142–145why, one step back
142 fn run_conclusion_command(
143 &self,144 command: &Command<'_>,145 output_policy: &CommandOutputPolicy,

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

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

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

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

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 148–150why, one step back
148 let error_output = "The conclusion command terminated with a non-zero exit code. \
149 Append ' || true' to the command if you are sure that this can be ignored.";150

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

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

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 152–153why, one step back
152 }
153

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 154–156why, one step back
154 /// Run the benchmark for a single command
155 pub fn run(&self) -> Result<BenchmarkResult> {156 if self.options.output_style != OutputStyleOption::Disabled {

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

lines 157–158why, one step back
157 console_writeln!(
158 io::stdout(),

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 159–161why, one step back
159 "{}{}: {}",
160 "Benchmark ".bold(),161 (self.number + 1).to_string().bold(),

Show unused parameters in command namesDavid Peterbefore adoptiona875276

line 162why, one step back
162 self.command.get_name_with_unused_parameters(),

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

line 163why, one step back
163 )?;

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 164–165why, one step back
164 }
165

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

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

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 167–168why, one step back
167 let mut all_succeeded = true;
168

Multiple output policiesDavid Peterbefore adoption99d24b7

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

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 171–182why, one step back
171 let preparation_command = self.options.preparation_command.as_ref().map(|values| {
172 let preparation_command = if values.len() == 1 {173 &values[0]174 } else {175 &values[self.number]176 };177 Command::new_parametrized(178 None,179 preparation_command,180 self.command.get_parameters().iter().cloned(),181 )182 });

Multiple output policiesDavid Peterbefore adoption99d24b7

line 183why, one step back
183

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

line 184why, one step back
184 let run_preparation_command = |iteration: executor::BenchmarkIteration| {

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 185–186why, one step back
185 preparation_command
186 .as_ref()

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

line 187why, one step back
187 .map(|cmd| self.run_preparation_command(cmd, output_policy, iteration))

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 188–190why, one step back
188 .transpose()
189 };190

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 191–202why, one step back
191 let conclusion_command = self.options.conclusion_command.as_ref().map(|values| {
192 let conclusion_command = if values.len() == 1 {193 &values[0]194 } else {195 &values[self.number]196 };197 Command::new_parametrized(198 None,199 conclusion_command,200 self.command.get_parameters().iter().cloned(),201 )202 });

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

line 203why, one step back
203 let run_conclusion_command = |iteration: executor::BenchmarkIteration| {

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 204–205why, one step back
204 conclusion_command
205 .as_ref()

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

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

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 207–209why, one step back
207 .transpose()
208 };209

Multiple output policiesDavid Peterbefore adoption99d24b7

line 210why, one step back
210 self.run_setup_command(self.command.get_parameters().iter().cloned(), output_policy)?;

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 211–223why, one step back
211
212 // Warmup phase213 if self.options.warmup_count > 0 {214 let progress_bar = if self.options.output_style != OutputStyleOption::Disabled {215 Some(get_progress_bar(216 self.options.warmup_count,217 "Performing warmup runs",218 self.options.output_style,219 ))220 } else {221 None222 };223

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 224why, one step back
224 for i in 0..self.options.warmup_count {

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

lines 225–226why, one step back
225 let warmup_iteration = BenchmarkIteration::Warmup(i);
226 let _ = run_preparation_command(warmup_iteration)?;

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

lines 227–228why, one step back
227 let _ = self.executor.run_command_and_measure(
228 self.command,

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

line 229why, one step back
229 warmup_iteration,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 230why, one step back
230 None,

Multiple output policiesDavid Peterbefore adoption99d24b7

line 231why, one step back
231 output_policy,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 232why, one step back
232 )?;

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

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

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 234–253why, one step back
234 if let Some(bar) = progress_bar.as_ref() {
235 bar.inc(1)236 }237 }238 if let Some(bar) = progress_bar.as_ref() {239 bar.finish_and_clear()240 }241 }242243 // Set up progress bar (and spinner for initial measurement)244 let progress_bar = if self.options.output_style != OutputStyleOption::Disabled {245 Some(get_progress_bar(246 self.options.run_bounds.min,247 "Initial time measurement",248 self.options.output_style,249 ))250 } else {251 None252 };253

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

lines 254–255why, one step back
254 let benchmark_iteration = BenchmarkIteration::Benchmark(0);
255 let preparation_result = run_preparation_command(benchmark_iteration)?;

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

line 256why, one step back
256 let preparation_overhead = preparation_result.map_or(Time::zero(), |res| {

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

lines 257–258why, one step back
257 res.time_wall_clock + self.executor.time_overhead()
258 });

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 259–260why, one step back
259
260 // Initial timing run

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

line 261why, one step back
261 let res = self.executor.run_command_and_measure(

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

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

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

line 263why, one step back
263 benchmark_iteration,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 264why, one step back
264 None,

Multiple output policiesDavid Peterbefore adoption99d24b7

line 265why, one step back
265 output_policy,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 266why, one step back
266 )?;

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

line 267why, one step back
267 let success = res.exit_status.success();

ran cargo fmtHumble Penguinbefore adoptionacf156e

line 268why, one step back
268

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

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

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

line 270why, one step back
270 let conclusion_overhead = conclusion_result.map_or(Time::zero(), |res| {

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

lines 271–272why, one step back
271 res.time_wall_clock + self.executor.time_overhead()
272 });

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

line 273why, one step back
273

ran cargo fmtHumble Penguinbefore adoptionacf156e

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

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

line 276why, one step back
276 / (res.time_wall_clock

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 277–278why, one step back
277 + self.executor.time_overhead()
278 + preparation_overhead

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

lines 279–280why, one step back
279 + conclusion_overhead))
280 .get::<ratio>() as u64;

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 281–295why, one step back
281
282 let count = {283 let min = cmp::max(runs_in_min_time, self.options.run_bounds.min);284285 self.options286 .run_bounds287 .max288 .as_ref()289 .map(|max| cmp::min(min, *max))290 .unwrap_or(min)291 };292293 let count_remaining = count - 1;294295 // Save the first result

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

line 296why, one step back
296 measurements.push(res);

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 297–308why, one step back
297
298 all_succeeded = all_succeeded && success;299300 // Re-configure the progress bar301 if let Some(bar) = progress_bar.as_ref() {302 bar.set_length(count)303 }304 if let Some(bar) = progress_bar.as_ref() {305 bar.inc(1)306 }307308 // Gather statistics (perform the actual benchmark)

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

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

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

lines 310–311why, one step back
310 let benchmark_iteration = BenchmarkIteration::Benchmark(i + 1);
311 run_preparation_command(benchmark_iteration)?;

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 312–313why, one step back
312
313 let msg = {

Merge pull request #967 from sharkdp/codex/quantity-formattingDavid Peterbefore adoptiona6c3010

lines 314–319why, one step back
314 let t_wall_clock_mean = measurements.time_wall_clock_mean();
315 let time_unit = self316 .options317 .time_unit318 .unwrap_or(t_wall_clock_mean.suitable_unit());319 let mean = t_wall_clock_mean.format(time_unit);

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 320–326why, one step back
320 format!("Current estimate: {}", mean.to_string().green())
321 };322323 if let Some(bar) = progress_bar.as_ref() {324 bar.set_message(msg.to_owned())325 }326

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

line 327why, one step back
327 let res = self.executor.run_command_and_measure(

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

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

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

line 329why, one step back
329 benchmark_iteration,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 330why, one step back
330 None,

Multiple output policiesDavid Peterbefore adoption99d24b7

line 331why, one step back
331 output_policy,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 332why, one step back
332 )?;

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

line 333why, one step back
333 let success = res.exit_status.success();

ran cargo fmtHumble Penguinbefore adoptionacf156e

line 334why, one step back
334

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

line 335why, one step back
335 measurements.push(res);

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 336–341why, one step back
336
337 all_succeeded = all_succeeded && success;338339 if let Some(bar) = progress_bar.as_ref() {340 bar.inc(1)341 }

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

line 342why, one step back
342

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

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

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 344–350why, one step back
344 }
345346 if let Some(bar) = progress_bar.as_ref() {347 bar.finish_and_clear()348 }349350 // Compute statistical quantities

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

lines 351–355why, one step back
351 let t_num = measurements.len();
352 let t_mean = measurements.time_wall_clock_mean();353 let t_stddev = measurements.stddev();354 let t_min = measurements.min();355 let t_max = measurements.max();

ran cargo fmtHumble Penguinbefore adoptionacf156e

line 356why, one step back
356

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

lines 357–358why, one step back
357 let user_mean = measurements.time_user_mean();
358 let system_mean = measurements.time_system_mean();

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 359–360why, one step back
359
360 // Formatting and console output

Merge pull request #967 from sharkdp/codex/quantity-formattingDavid Peterbefore adoptiona6c3010

lines 361–364why, one step back
361 let time_unit = self.options.time_unit.unwrap_or(t_mean.suitable_unit());
362 let mean_str = t_mean.format(time_unit);363 let min_str = t_min.format(time_unit);364 let max_str = t_max.format(time_unit);

style: simplify string interpolationHamir Mahalbefore adoptionef12632

line 365why, one step back
365 let num_str = format!("{t_num} runs");

ran cargo fmtHumble Penguinbefore adoptionacf156e

line 366why, one step back
366

Merge pull request #967 from sharkdp/codex/quantity-formattingDavid Peterbefore adoptiona6c3010

lines 367–368why, one step back
367 let user_str = user_mean.format(time_unit);
368 let system_str = system_mean.format(time_unit);

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 369–370why, one step back
369
370 if self.options.output_style != OutputStyleOption::Disabled {

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

line 371why, one step back
371 let mut stdout = io::stdout().lock();

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

line 372why, one step back
372 if measurements.len() == 1 {

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

lines 373–374why, one step back
373 console_writeln!(
374 stdout,

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 375–380why, one step back
375 " Time ({} ≡): {:>8} {:>8} [User: {}, System: {}]",
376 "abs".green().bold(),377 mean_str.green().bold(),378 " ", // alignment379 user_str.blue(),380 system_str.blue()

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

line 381why, one step back
381 )?;

ran cargo fmtHumble Penguinbefore adoptionacf156e

line 382why, one step back
382 } else {

Merge pull request #967 from sharkdp/codex/quantity-formattingDavid Peterbefore adoptiona6c3010

line 383why, one step back
383 let stddev_str = t_stddev.unwrap().format(time_unit);

ran cargo fmtHumble Penguinbefore adoptionacf156e

line 384why, one step back
384

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

lines 385–386why, one step back
385 console_writeln!(
386 stdout,

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 387–393why, one step back
387 " Time ({} ± {}): {:>8} ± {:>8} [User: {}, System: {}]",
388 "mean".green().bold(),389 "σ".green(),390 mean_str.green().bold(),391 stddev_str.green(),392 user_str.blue(),393 system_str.blue()

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

line 394why, one step back
394 )?;

ran cargo fmtHumble Penguinbefore adoptionacf156e

line 395why, one step back
395

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

lines 396–397why, one step back
396 console_writeln!(
397 stdout,

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 398–403why, one step back
398 " Range ({} … {}): {:>8} … {:>8} {}",
399 "min".cyan(),400 "max".purple(),401 min_str.cyan(),402 max_str.purple(),403 num_str.dimmed()

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

line 404why, one step back
404 )?;

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 405–412why, one step back
405 }
406 }407408 // Warnings409 let mut warnings = vec![];410411 // Check execution time412 if matches!(self.options.executor_kind, ExecutorKind::Shell(_))

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

lines 413–415why, one step back
413 && measurements
414 .wall_clock_times()415 .any(|t| t < MIN_EXECUTION_TIME)

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 416–419why, one step back
416 {
417 warnings.push(Warnings::FastExecutionTime);418 }419

Spelling and grammar fixesVille Skyttäbefore adoption178bdaa

line 420why, one step back
420 // Check program exit codes

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 421–425why, one step back
421 if !all_succeeded {
422 warnings.push(Warnings::NonZeroExitCode);423 }424425 // Run outlier detection

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

line 426why, one step back
426 let scores = measurements.modified_zscores();

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 427–440why, one step back
427
428 let outlier_warning_options = OutlierWarningOptions {429 warmup_in_use: self.options.warmup_count > 0,430 prepare_in_use: self431 .options432 .preparation_command433 .as_ref()434 .map(|v| v.len())435 .unwrap_or(0)436 > 0,437 };438439 if scores[0] > OUTLIER_THRESHOLD {440 warnings.push(Warnings::SlowInitialRun(

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

line 441why, one step back
441 measurements.wall_clock_times().next().unwrap(),

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 442–448why, one step back
442 outlier_warning_options,
443 ));444 } else if scores.iter().any(|&s| s.abs() > OUTLIER_THRESHOLD) {445 warnings.push(Warnings::OutliersDetected(outlier_warning_options));446 }447448 if !warnings.is_empty() {

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

lines 449–450why, one step back
449 let mut stderr = io::stderr().lock();
450 console_writeln!(stderr, " ")?;

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 451–452why, one step back
451
452 for warning in &warnings {

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

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

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 454–457why, one step back
454 }
455 }456457 if self.options.output_style != OutputStyleOption::Disabled {

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

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

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 459–460why, one step back
459 }
460

Multiple output policiesDavid Peterbefore adoption99d24b7

line 461why, one step back
461 self.run_cleanup_command(self.command.get_parameters().iter().cloned(), output_policy)?;

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 462–463why, one step back
462
463 Ok(BenchmarkResult {

Show unused parameters in command namesDavid Peterbefore adoptiona875276

lines 464–465why, one step back
464 command: self.command.get_name(),
465 command_with_unused_parameters: self.command.get_name_with_unused_parameters(),

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

line 466why, one step back
466 measurements,

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 467–470why, one step back
467 parameters: self
468 .command469 .get_parameters()470 .iter()

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

lines 471–479why, one step back
471 .map(|(name, value)| {
472 (473 name.to_string(),474 Parameter {475 value: value.to_string(),476 is_unused: self.command.is_parameter_unused(name),477 },478 )479 })

ran cargo fmtHumble Penguinbefore adoptionacf156e

lines 480–483why, one step back
480 .collect(),
481 })482 }483}