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
Provenance
- Commit
35c94a0- Tree
1749f0b- Author
David Peter <sharkdp@users.noreply.github.com>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
750fe11
4 files changed+39 added−36 removed
modified:src/benchmark/executor.rs+15 added-14 removed
77 unmodified lines78 79 let result = execute_and_measure(command)80 .with_context(|| format!("Failed to run command '{command_name}'"))?;81 82- if !result.status.success() {82+ if !result.exit_status.success() {83 use crate::util::exit_code::extract_exit_code;84 85 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 true11 unmodified lines106 };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}")113 114 ),87 unmodified lines202 )?;203 204 // 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 lines251 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 lines267 bar.finish_and_clear()268 }269 270 self.shell_spawning_time = Some(Measurement {270- time_real: mean(×_real),271+ time_wall_clock: mean(×_real),272 time_user: mean(×_user),273 time_system: mean(×_system),273- memory_usage_byte: 0,274- status: ExitStatus::default(),274+ peak_memory_usage: 0,275+ exit_status: ExitStatus::default(),276 });277 278 Ok(())279 }280 281 fn time_overhead(&self) -> Second {281- self.shell_spawning_time.unwrap().time_real282+ self.shell_spawning_time.unwrap().time_wall_clock283 }284 }285 286 #[derive(Clone)]24 unmodified lines311 _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 };319 320 #[cfg(windows)]320- let status = {321+ let exit_status = {322 use std::os::windows::process::ExitStatusExt;323 ExitStatus::from_raw(0)324 };325 326 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 }334 335 fn calibrate(&mut self) -> Result<()> {15 unmodified linesmodified:src/benchmark/measurement.rs+3 added-3 removed
4 unmodified lines5 /// Performance measurements and exit status from running a single command6 #[derive(Debug, Default, Copy, Clone)]7 pub struct Measurement {8 /// Wall clock time9- pub time_real: Second,9+ pub time_wall_clock: Second,10 11 /// Time spent in user mode12 pub time_user: Second,13 14 /// Time spent in kernel mode15 pub time_system: Second,16 17 /// Maximum amount of memory used, in bytes18- pub memory_usage_byte: u64,18+ pub peak_memory_usage: u64,19 20 /// 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 lines240 None241 };242 243 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+ });247 248 // 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();256 257 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+ });261 262 // 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 lines279 280 let count_remaining = count - 1;281 282 // 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));288 289 all_succeeded = all_succeeded && success;290 291 // Re-configure the progress bar22 unmodified lines314 BenchmarkIteration::Benchmark(i + 1),315 None,316 output_policy,317 )?;316- let success = res.status.success();318+ let success = res.exit_status.success();319 318- 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));325 326 all_succeeded = all_succeeded && success;327 328 if let Some(bar) = progress_bar.as_ref() {147 unmodified linesmodified:src/timer/mod.rs+6 added-6 removed
93 unmodified lines94 // Handle CommandOutputPolicy::Pipe95 discard(output);96 }97 98- let status = child.wait()?;98+ let exit_status = child.wait()?;99 100- 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();102 103 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 }