Skip to content
Myr

executor.rs

This file

Path

src/benchmark/executor.rs

401 lines · 12.8 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.

fmt: apply cargo fmt suggestionsPedro Witzelbefore adoptionc2f99e5

line 1why, one step back
1#[cfg(windows)]

bug: quoting failure on windows-platform (#296)Pedro Witzelbefore adoptionbece2ea

line 2why, one step back
2use std::os::windows::process::CommandExt;

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

lines 3–4why, one step back
3use std::process::ExitStatus;
4

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

lines 5–6why, one step back
5use crate::benchmark::measurement::Measurement;
6use crate::benchmark::measurement::Measurements;

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

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

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

line 8why, one step back
8use crate::options::{CmdFailureAction, CommandOutputPolicy, Options, OutputStyleOption, Shell};

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

line 9why, one step back
9use crate::output::progress_bar::get_progress_bar;

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

line 10why, one step back
10use crate::quantity::{second, Information, Time, Zero};

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

line 11why, one step back
11use crate::timer::execute_and_measure;

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

lines 12–15why, one step back
12use crate::util::randomized_environment_offset;
1314use anyhow::{bail, Context, Result};15

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

line 16why, one step back
16#[derive(Clone, Copy)]

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

lines 17–32why, one step back
17pub enum BenchmarkIteration {
18 NonBenchmarkRun,19 Warmup(u64),20 Benchmark(u64),21}2223impl BenchmarkIteration {24 pub fn to_env_var_value(&self) -> Option<String> {25 match self {26 BenchmarkIteration::NonBenchmarkRun => None,27 BenchmarkIteration::Warmup(i) => Some(format!("warmup-{}", i)),28 BenchmarkIteration::Benchmark(i) => Some(format!("{}", i)),29 }30 }31}32

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

lines 33–37why, one step back
33pub trait Executor {
34 /// Run the given command and measure the execution time35 fn run_command_and_measure(36 &self,37 command: &Command<'_>,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 38why, one step back
38 iteration: BenchmarkIteration,

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

line 39why, one step back
39 command_failure_action: Option<CmdFailureAction>,

Multiple output policiesDavid Peterbefore adoption99d24b7

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

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

line 41why, one step back
41 ) -> Result<Measurement>;

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

line 42why, one step back
42

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

lines 43–57why, one step back
43 /// Run a lifecycle command through a shell, always treating failures as errors.
44 fn run_intermediate_command_and_measure(45 &self,46 command: &Command<'_>,47 iteration: BenchmarkIteration,48 output_policy: &CommandOutputPolicy,49 ) -> Result<Measurement> {50 self.run_command_and_measure(51 command,52 iteration,53 Some(CmdFailureAction::RaiseError),54 output_policy,55 )56 }57

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

lines 58–67why, one step back
58 /// Perform a calibration of this executor. For example,
59 /// when running commands through a shell, we need to60 /// measure the shell spawning time separately in order61 /// to subtract it from the full runtime later.62 fn calibrate(&mut self) -> Result<()>;6364 /// Return the time overhead for this executor when65 /// performing a measurement. This should return the time66 /// that is being used in addition to the actual runtime67 /// of the command.

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

line 68why, one step back
68 fn time_overhead(&self) -> Time;

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

lines 69–72why, one step back
69}
7071fn run_command_and_measure_common(72 mut command: std::process::Command,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 73why, one step back
73 iteration: BenchmarkIteration,

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

lines 74–75why, one step back
74 command_failure_action: Option<CmdFailureAction>,
75 options: &Options,

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

lines 76–77why, one step back
76 command_output_policy: &CommandOutputPolicy,
77 command_name: &str,

Support hardware counters (instructions, cache misses, ...) (#983)David Peterbefore adoptionbc3a3f0

line 78why, one step back
78 collect_hardware_counters: bool,

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

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

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

line 80why, one step back
80 let stdin = options.command_input_policy.get_stdin()?;

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

lines 81–88why, one step back
81 let (stdout, stderr) = command_output_policy.get_stdout_stderr()?;
82 command.stdin(stdin).stdout(stdout).stderr(stderr);8384 command.env(85 "HYPERFINE_RANDOMIZED_ENVIRONMENT_OFFSET",86 randomized_environment_offset::value(),87 );88

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

lines 89–92why, one step back
89 if let Some(value) = iteration.to_env_var_value() {
90 command.env("HYPERFINE_ITERATION", value);91 }92

Support hardware counters (instructions, cache misses, ...) (#983)David Peterbefore adoptionbc3a3f0

line 93why, one step back
93 let measurement = execute_and_measure(command, collect_hardware_counters)

style: simplify string interpolationHamir Mahalbefore adoptionef12632

line 94why, one step back
94 .with_context(|| format!("Failed to run command '{command_name}'"))?;

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

line 95why, one step back
95

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

line 96why, one step back
96 if !measurement.exit_status.success() {

Support list of exit codes in --ignore-failureDavid Peterbefore adoptionb5a6860

lines 97–98why, one step back
97 use crate::util::exit_code::extract_exit_code;
98

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

lines 99–103why, one step back
99 let show_ignore_failure_hint = command_failure_action.is_none();
100 let should_fail = match command_failure_action101 .as_ref()102 .unwrap_or(&options.command_failure_action)103 {

Support list of exit codes in --ignore-failureDavid Peterbefore adoptionb5a6860

lines 104–105why, one step back
104 CmdFailureAction::RaiseError => true,
105 CmdFailureAction::IgnoreAllFailures => false,

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

line 106why, one step back
106 CmdFailureAction::IgnoreSpecificFailures(codes) => {

Support list of exit codes in --ignore-failureDavid Peterbefore adoptionb5a6860

line 107why, one step back
107 // Only fail if the exit code is not in the list of codes to ignore

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

line 108why, one step back
108 if let Some(exit_code) = extract_exit_code(measurement.exit_status) {

Support list of exit codes in --ignore-failureDavid Peterbefore adoptionb5a6860

lines 109–114why, one step back
109 !codes.contains(&exit_code)
110 } else {111 // If we can't extract an exit code, treat it as a failure112 true113 }114 }

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

lines 115–116why, one step back
115 };
116

Support list of exit codes in --ignore-failureDavid Peterbefore adoptionb5a6860

lines 117–124why, one step back
117 if should_fail {
118 let when = match iteration {119 BenchmarkIteration::NonBenchmarkRun => "a non-benchmark run".to_string(),120 BenchmarkIteration::Warmup(0) => "the first warmup run".to_string(),121 BenchmarkIteration::Warmup(i) => format!("warmup iteration {i}"),122 BenchmarkIteration::Benchmark(0) => "the first benchmark run".to_string(),123 BenchmarkIteration::Benchmark(i) => format!("benchmark iteration {i}"),124 };

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

lines 125–127why, one step back
125 let cause = measurement.exit_status.code().map_or_else(
126 || "was terminated by a signal".to_owned(),127 |code| format!("terminated with non-zero exit code {code}"),

Support list of exit codes in --ignore-failureDavid Peterbefore adoptionb5a6860

line 128why, one step back
128 );

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

lines 129–135why, one step back
129 let hint = if show_ignore_failure_hint {
130 " Use the '-i'/'--ignore-failure' option if you want to ignore this. \131 Alternatively, use the '--show-output' option to debug what went wrong."132 } else {133 " Use the '--show-output' option to debug what went wrong."134 };135 bail!("Command '{command_name}' {cause} in {when}.{hint}");

Support list of exit codes in --ignore-failureDavid Peterbefore adoptionb5a6860

line 136why, one step back
136 }

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

lines 137–138why, one step back
137 }
138

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

line 139why, one step back
139 Ok(measurement)

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

lines 140–151why, one step back
140}
141142pub struct RawExecutor<'a> {143 options: &'a Options,144}145146impl<'a> RawExecutor<'a> {147 pub fn new(options: &'a Options) -> Self {148 RawExecutor { options }149 }150}151

apply clippy advices on executor/commands lifetimes.David Carlierbefore adoption2899deb

line 152why, one step back
152impl Executor for RawExecutor<'_> {

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

lines 153–155why, one step back
153 fn run_command_and_measure(
154 &self,155 command: &Command<'_>,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 156why, one step back
156 iteration: BenchmarkIteration,

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

line 157why, one step back
157 command_failure_action: Option<CmdFailureAction>,

Multiple output policiesDavid Peterbefore adoption99d24b7

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

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

lines 159–160why, one step back
159 ) -> Result<Measurement> {
160 run_command_and_measure_common(

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

line 161why, one step back
161 command.get_command()?,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 162why, one step back
162 iteration,

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

lines 163–164why, one step back
163 command_failure_action,
164 self.options,

Multiple output policiesDavid Peterbefore adoption99d24b7

line 165why, one step back
165 output_policy,

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

line 166why, one step back
166 &command.get_command_line(),

Support hardware counters (instructions, cache misses, ...) (#983)David Peterbefore adoptionbc3a3f0

line 167why, one step back
167 matches!(iteration, BenchmarkIteration::Benchmark(_)),

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

line 168why, one step back
168 )

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

lines 169–170why, one step back
169 }
170

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

lines 171–182why, one step back
171 fn run_intermediate_command_and_measure(
172 &self,173 command: &Command<'_>,174 iteration: BenchmarkIteration,175 output_policy: &CommandOutputPolicy,176 ) -> Result<Measurement> {177 // Keep shell startup in the hook's duration: raw benchmarks have no178 // calibrated shell overhead to add back when estimating the run count.179 ShellExecutor::new(&Shell::platform_default(), self.options)180 .run_intermediate_command_and_measure(command, iteration, output_policy)181 }182

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

lines 183–186why, one step back
183 fn calibrate(&mut self) -> Result<()> {
184 Ok(())185 }186

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

lines 187–188why, one step back
187 fn time_overhead(&self) -> Time {
188 Time::zero()

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

lines 189–194why, one step back
189 }
190}191192pub struct ShellExecutor<'a> {193 options: &'a Options,194 shell: &'a Shell,

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

line 195why, one step back
195 shell_spawning_time: Option<Measurement>,

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

lines 196–207why, one step back
196}
197198impl<'a> ShellExecutor<'a> {199 pub fn new(shell: &'a Shell, options: &'a Options) -> Self {200 ShellExecutor {201 shell,202 options,203 shell_spawning_time: None,204 }205 }206}207

apply clippy advices on executor/commands lifetimes.David Carlierbefore adoption2899deb

line 208why, one step back
208impl Executor for ShellExecutor<'_> {

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

lines 209–211why, one step back
209 fn run_command_and_measure(
210 &self,211 command: &Command<'_>,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 212why, one step back
212 iteration: BenchmarkIteration,

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

line 213why, one step back
213 command_failure_action: Option<CmdFailureAction>,

Multiple output policiesDavid Peterbefore adoption99d24b7

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

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

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

bug: quoting failure on windows-platform (#296)Pedro Witzelbefore adoptionbece2ea

line 216why, one step back
216 let on_windows_cmd = cfg!(windows) && *self.shell == Shell::Default("cmd.exe");

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

line 217why, one step back
217 let mut command_builder = self.shell.command();

Add --env for benchmark environment overridesDavid Peterbefore adoption6dddb02

line 218why, one step back
218 command_builder.envs(command.get_environment());

fmt: apply cargo fmt suggestionsPedro Witzelbefore adoptionc2f99e5

line 219why, one step back
219 command_builder.arg(if on_windows_cmd { "/C" } else { "-c" });

bug: quoting failure on windows-platform (#296)Pedro Witzelbefore adoptionbece2ea

line 220why, one step back
220

fmt: apply cargo fmt suggestionsPedro Witzelbefore adoptionc2f99e5

lines 221–222why, one step back
221 // Windows needs special treatment for its behavior on parsing cmd arguments
222 if on_windows_cmd {

cfg: adding more pre-processing for windows-only parserPedro Witzelbefore adoptionae9b0bb

line 223why, one step back
223 #[cfg(windows)]

fmt: apply cargo fmt suggestionsPedro Witzelbefore adoptionc2f99e5

lines 224–227why, one step back
224 command_builder.raw_arg(command.get_command_line());
225 } else {226 command_builder.arg(command.get_command_line());227 }

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

line 228why, one step back
228

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

line 229why, one step back
229 let mut measurement = run_command_and_measure_common(

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

line 230why, one step back
230 command_builder,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 231why, one step back
231 iteration,

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

lines 232–233why, one step back
232 command_failure_action,
233 self.options,

Multiple output policiesDavid Peterbefore adoption99d24b7

line 234why, one step back
234 output_policy,

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

line 235why, one step back
235 &command.get_command_line(),

Support hardware counters (instructions, cache misses, ...) (#983)David Peterbefore adoptionbc3a3f0

line 236why, one step back
236 false,

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

lines 237–239why, one step back
237 )?;
238239 // Subtract shell spawning time

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

lines 240–245why, one step back
240 fn ensure_non_negative(time: Time) -> Time {
241 if time < Time::zero() {242 Time::zero()243 } else {244 time245 }

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

lines 246–247why, one step back
246 }
247

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

lines 248–254why, one step back
248 if let Some(ref spawning_time) = self.shell_spawning_time {
249 measurement.time_wall_clock =250 ensure_non_negative(measurement.time_wall_clock - spawning_time.time_wall_clock);251 measurement.time_user =252 ensure_non_negative(measurement.time_user - spawning_time.time_user);253 measurement.time_system =254 ensure_non_negative(measurement.time_system - spawning_time.time_system);

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

line 255why, one step back
255 measurement.time_cpu = measurement.time_user + measurement.time_system;

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

lines 256–258why, one step back
256 }
257258 Ok(measurement)

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

lines 259–273why, one step back
259 }
260261 /// Measure the average shell spawning time262 fn calibrate(&mut self) -> Result<()> {263 const COUNT: u64 = 50;264 let progress_bar = if self.options.output_style != OutputStyleOption::Disabled {265 Some(get_progress_bar(266 COUNT,267 "Measuring shell spawning time",268 self.options.output_style,269 ))270 } else {271 None272 };273

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

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

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

lines 275–277why, one step back
275
276 for _ in 0..COUNT {277 // Just run the shell without any command

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

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

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

lines 279–281why, one step back
279 &Command::new(None, ""),
280 BenchmarkIteration::NonBenchmarkRun,281 None,

Multiple output policiesDavid Peterbefore adoption99d24b7

line 282why, one step back
282 &CommandOutputPolicy::Null,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 283why, one step back
283 );

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

line 284why, one step back
284

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

line 285why, one step back
285 match measurement {

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

lines 286–297why, one step back
286 Err(_) => {
287 let shell_cmd = if cfg!(windows) {288 format!("{} /C \"\"", self.shell)289 } else {290 format!("{} -c \"\"", self.shell)291 };292293 bail!(294 "Could not measure shell execution time. Make sure you can run '{}'.",295 shell_cmd296 );297 }

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

lines 298–299why, one step back
298 Ok(result) => {
299 measurements.push(result);

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

lines 300–311why, one step back
300 }
301 }302303 if let Some(bar) = progress_bar.as_ref() {304 bar.inc(1)305 }306 }307308 if let Some(bar) = progress_bar.as_ref() {309 bar.finish_and_clear()310 }311

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

line 312why, one step back
312 self.shell_spawning_time = Some(Measurement {

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

line 313why, one step back
313 time_wall_clock: measurements.time_wall_clock_mean(),

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

line 314why, one step back
314 time_cpu: measurements.time_user_mean() + measurements.time_system_mean(),

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

lines 315–316why, one step back
315 time_user: measurements.time_user_mean(),
316 time_system: measurements.time_system_mean(),

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

line 317why, one step back
317 memory_peak_resident: None,

Support hardware counters (instructions, cache misses, ...) (#983)David Peterbefore adoptionbc3a3f0

line 318why, one step back
318 hardware_counters: Default::default(),

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

line 319why, one step back
319 exit_status: ExitStatus::default(),

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

lines 320–324why, one step back
320 });
321322 Ok(())323 }324

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

line 325why, one step back
325 fn time_overhead(&self) -> Time {

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

line 326why, one step back
326 self.shell_spawning_time.as_ref().unwrap().time_wall_clock

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

lines 327–339why, one step back
327 }
328}329330#[derive(Clone)]331pub struct MockExecutor {332 shell: Option<String>,333}334335impl MockExecutor {336 pub fn new(shell: Option<String>) -> Self {337 MockExecutor { shell }338 }339

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

line 340why, one step back
340 fn extract_time<S: AsRef<str>>(sleep_command: S) -> Time {

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

line 341why, one step back
341 assert!(sleep_command.as_ref().starts_with("sleep "));

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

lines 342–348why, one step back
342 Time::new::<second>(
343 sleep_command344 .as_ref()345 .trim_start_matches("sleep ")346 .parse::<f64>()347 .unwrap(),348 )

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

lines 349–355why, one step back
349 }
350}351352impl Executor for MockExecutor {353 fn run_command_and_measure(354 &self,355 command: &Command<'_>,

Add iteration information to failure error messageDavid Peterbefore adoption83f04cd

line 356why, one step back
356 _iteration: BenchmarkIteration,

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

line 357why, one step back
357 _command_failure_action: Option<CmdFailureAction>,

Multiple output policiesDavid Peterbefore adoption99d24b7

line 358why, one step back
358 _output_policy: &CommandOutputPolicy,

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

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

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

line 360why, one step back
360 #[cfg(unix)]

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

line 361why, one step back
361 let exit_status = {

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

lines 362–366why, one step back
362 use std::os::unix::process::ExitStatusExt;
363 ExitStatus::from_raw(0)364 };365366 #[cfg(windows)]

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

line 367why, one step back
367 let exit_status = {

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

lines 368–371why, one step back
368 use std::os::windows::process::ExitStatusExt;
369 ExitStatus::from_raw(0)370 };371

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

line 372why, one step back
372 Ok(Measurement {

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

line 373why, one step back
373 time_wall_clock: Self::extract_time(command.get_command_line()),

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

line 374why, one step back
374 time_cpu: Time::zero(),

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

lines 375–376why, one step back
375 time_user: Time::zero(),
376 time_system: Time::zero(),

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

line 377why, one step back
377 memory_peak_resident: Some(Information::zero()),

Support hardware counters (instructions, cache misses, ...) (#983)David Peterbefore adoptionbc3a3f0

line 378why, one step back
378 hardware_counters: Default::default(),

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

line 379why, one step back
379 exit_status,

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

line 380why, one step back
380 })

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

lines 381–386why, one step back
381 }
382383 fn calibrate(&mut self) -> Result<()> {384 Ok(())385 }386

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

line 387why, one step back
387 fn time_overhead(&self) -> Time {

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

line 388why, one step back
388 match &self.shell {

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

line 389why, one step back
389 None => Time::zero(),

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

lines 390–396why, one step back
390 Some(shell) => Self::extract_time(shell),
391 }392 }393}394395#[test]396fn test_mock_executor_extract_time() {

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

lines 397–400why, one step back
397 assert_eq!(
398 MockExecutor::extract_time("sleep 0.1"),399 Time::new::<second>(0.1)400 );

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

line 401why, one step back
401}