Skip to content
Myr

Clarify internal measurement field names

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Peter · committed by David Peter · parent 750fe11 · Browse files · 4 files+39 added−36 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+39 added−36 removed

  • other:+39 added−36 removed

4 files+39 added−36 removed

modified:src/benchmark/executor.rs+15 added-14 removed
77 unmodified lines
7879 let result = execute_and_measure(command)80 .with_context(|| format!("Failed to run command '{command_name}'"))?;8182 if !result.status.success() {82 if !result.exit_status.success() {83 use crate::util::exit_code::extract_exit_code;8485 let should_fail = match command_failure_action {86 CmdFailureAction::RaiseError => true,87 CmdFailureAction::IgnoreAllFailures => false,88 CmdFailureAction::IgnoreSpecificFailures(ref codes) => {89 // Only fail if the exit code is not in the list of codes to ignore90 if let Some(exit_code) = extract_exit_code(result.status) {90 if let Some(exit_code) = extract_exit_code(result.exit_status) {91 !codes.contains(&exit_code)92 } else {93 // If we can't extract an exit code, treat it as a failure94 true
11 unmodified lines
106 };107 bail!(108 "{cause} in {when}. Use the '-i'/'--ignore-failure' option if you want to ignore this. \109 Alternatively, use the '--show-output' option to debug what went wrong.",110 cause=result.status.code().map_or(110 cause=result.exit_status.code().map_or(111 "The process has been terminated by a signal".into(),112 |c| format!("Command terminated with non-zero exit code {c}")113114 ),
87 unmodified lines
202 )?;203204 // Subtract shell spawning time205 if let Some(spawning_time) = self.shell_spawning_time {206 result.time_real = (result.time_real - spawning_time.time_real).max(0.0);206 result.time_wall_clock =207 (result.time_wall_clock - spawning_time.time_wall_clock).max(0.0);208 result.time_user = (result.time_user - spawning_time.time_user).max(0.0);209 result.time_system = (result.time_system - spawning_time.time_system).max(0.0);210 }211
39 unmodified lines
251 shell_cmd252 );253 }254 Ok(r) => {254 times_real.push(r.time_real);255 times_real.push(r.time_wall_clock);256 times_user.push(r.time_user);257 times_system.push(r.time_system);258 }259 }
7 unmodified lines
267 bar.finish_and_clear()268 }269270 self.shell_spawning_time = Some(Measurement {270 time_real: mean(&times_real),271 time_wall_clock: mean(&times_real),272 time_user: mean(&times_user),273 time_system: mean(&times_system),273 memory_usage_byte: 0,274 status: ExitStatus::default(),274 peak_memory_usage: 0,275 exit_status: ExitStatus::default(),276 });277278 Ok(())279 }280281 fn time_overhead(&self) -> Second {281 self.shell_spawning_time.unwrap().time_real282 self.shell_spawning_time.unwrap().time_wall_clock283 }284}285286#[derive(Clone)]
24 unmodified lines
311 _command_failure_action: Option<CmdFailureAction>,312 _output_policy: &CommandOutputPolicy,313 ) -> Result<Measurement> {314 #[cfg(unix)]314 let status = {315 let exit_status = {316 use std::os::unix::process::ExitStatusExt;317 ExitStatus::from_raw(0)318 };319320 #[cfg(windows)]320 let status = {321 let exit_status = {322 use std::os::windows::process::ExitStatusExt;323 ExitStatus::from_raw(0)324 };325326 Ok(Measurement {326 time_real: Self::extract_time(command.get_command_line()),327 time_wall_clock: Self::extract_time(command.get_command_line()),328 time_user: 0.0,329 time_system: 0.0,329 memory_usage_byte: 0,330 status,330 peak_memory_usage: 0,331 exit_status,332 })333 }334335 fn calibrate(&mut self) -> Result<()> {
15 unmodified lines
modified:src/benchmark/measurement.rs+3 added-3 removed
4 unmodified lines
5/// Performance measurements and exit status from running a single command6#[derive(Debug, Default, Copy, Clone)]7pub struct Measurement {8 /// Wall clock time9 pub time_real: Second,9 pub time_wall_clock: Second,1011 /// Time spent in user mode12 pub time_user: Second,1314 /// Time spent in kernel mode15 pub time_system: Second,1617 /// Maximum amount of memory used, in bytes18 pub memory_usage_byte: u64,18 pub peak_memory_usage: u64,1920 /// The exit status of the process21 pub status: ExitStatus,21 pub exit_status: ExitStatus,22}
modified:src/benchmark/mod.rs+15 added-13 removed
239 unmodified lines
240 None241 };242243 let preparation_result = run_preparation_command()?;244 let preparation_overhead =245 preparation_result.map_or(0.0, |res| res.time_real + self.executor.time_overhead());244 let preparation_overhead = preparation_result.map_or(0.0, |res| {245 res.time_wall_clock + self.executor.time_overhead()246 });247248 // Initial timing run249 let res = self.executor.run_command_and_measure(250 self.command,251 BenchmarkIteration::Benchmark(0),252 None,253 output_policy,254 )?;254 let success = res.status.success();255 let success = res.exit_status.success();256257 let conclusion_result = run_conclusion_command()?;257 let conclusion_overhead =258 conclusion_result.map_or(0.0, |res| res.time_real + self.executor.time_overhead());258 let conclusion_overhead = conclusion_result.map_or(0.0, |res| {259 res.time_wall_clock + self.executor.time_overhead()260 });261262 // Determine number of benchmark runs263 let runs_in_min_time = (self.options.min_benchmarking_time262 / (res.time_real264 / (res.time_wall_clock265 + self.executor.time_overhead()266 + preparation_overhead267 + conclusion_overhead)) as u64;268
10 unmodified lines
279280 let count_remaining = count - 1;281282 // Save the first result281 times_real.push(res.time_real);283 times_real.push(res.time_wall_clock);284 times_user.push(res.time_user);285 times_system.push(res.time_system);284 memory_usage_byte.push(res.memory_usage_byte);285 exit_codes.push(extract_exit_code(res.status));286 memory_usage_byte.push(res.peak_memory_usage);287 exit_codes.push(extract_exit_code(res.exit_status));288289 all_succeeded = all_succeeded && success;290291 // Re-configure the progress bar
22 unmodified lines
314 BenchmarkIteration::Benchmark(i + 1),315 None,316 output_policy,317 )?;316 let success = res.status.success();318 let success = res.exit_status.success();319318 times_real.push(res.time_real);320 times_real.push(res.time_wall_clock);321 times_user.push(res.time_user);322 times_system.push(res.time_system);321 memory_usage_byte.push(res.memory_usage_byte);322 exit_codes.push(extract_exit_code(res.status));323 memory_usage_byte.push(res.peak_memory_usage);324 exit_codes.push(extract_exit_code(res.exit_status));325326 all_succeeded = all_succeeded && success;327328 if let Some(bar) = progress_bar.as_ref() {
147 unmodified lines
modified:src/timer/mod.rs+6 added-6 removed
93 unmodified lines
94 // Handle CommandOutputPolicy::Pipe95 discard(output);96 }9798 let status = child.wait()?;98 let exit_status = child.wait()?;99100 let time_real = wallclock_timer.stop();101 let (time_user, time_system, memory_usage_byte) = cpu_timer.stop();100 let time_wall_clock = wallclock_timer.stop();101 let (time_user, time_system, peak_memory_usage) = cpu_timer.stop();102103 Ok(Measurement {104 time_real,104 time_wall_clock,105 time_user,106 time_system,107 memory_usage_byte,108 status,107 peak_memory_usage,108 exit_status,109 })110}