Clarify internal measurement field names

This commit is contained in:
David Peter committed 2026-10-05 10:09:41 +02:00
1 parent 750fe11b85
commit 35c94a0e36
4 files changed
+39 -36

No files matched your search

+15 -14
View File
@@ -79,7 +79,7 @@ fn run_command_and_measure_common(
let result = execute_and_measure(command)
.with_context(|| format!("Failed to run command '{command_name}'"))?;
if !result.status.success() {
if !result.exit_status.success() {
use crate::util::exit_code::extract_exit_code;
let should_fail = match command_failure_action {
@@ -87,7 +87,7 @@ fn run_command_and_measure_common(
CmdFailureAction::IgnoreAllFailures => false,
CmdFailureAction::IgnoreSpecificFailures(ref codes) => {
// Only fail if the exit code is not in the list of codes to ignore
if let Some(exit_code) = extract_exit_code(result.status) {
if let Some(exit_code) = extract_exit_code(result.exit_status) {
!codes.contains(&exit_code)
} else {
// If we can't extract an exit code, treat it as a failure
@@ -107,7 +107,7 @@ fn run_command_and_measure_common(
bail!(
"{cause} in {when}. Use the '-i'/'--ignore-failure' option if you want to ignore this. \
Alternatively, use the '--show-output' option to debug what went wrong.",
cause=result.status.code().map_or(
cause=result.exit_status.code().map_or(
"The process has been terminated by a signal".into(),
|c| format!("Command terminated with non-zero exit code {c}")
@@ -203,7 +203,8 @@ impl Executor for ShellExecutor<'_> {
// Subtract shell spawning time
if let Some(spawning_time) = self.shell_spawning_time {
result.time_real = (result.time_real - spawning_time.time_real).max(0.0);
result.time_wall_clock =
(result.time_wall_clock - spawning_time.time_wall_clock).max(0.0);
result.time_user = (result.time_user - spawning_time.time_user).max(0.0);
result.time_system = (result.time_system - spawning_time.time_system).max(0.0);
}
@@ -251,7 +252,7 @@ impl Executor for ShellExecutor<'_> {
);
}
Ok(r) => {
times_real.push(r.time_real);
times_real.push(r.time_wall_clock);
times_user.push(r.time_user);
times_system.push(r.time_system);
}
@@ -267,18 +268,18 @@ impl Executor for ShellExecutor<'_> {
}
self.shell_spawning_time = Some(Measurement {
time_real: mean(&times_real),
time_wall_clock: mean(&times_real),
time_user: mean(&times_user),
time_system: mean(&times_system),
memory_usage_byte: 0,
status: ExitStatus::default(),
peak_memory_usage: 0,
exit_status: ExitStatus::default(),
});
Ok(())
}
fn time_overhead(&self) -> Second {
self.shell_spawning_time.unwrap().time_real
self.shell_spawning_time.unwrap().time_wall_clock
}
}
@@ -311,23 +312,23 @@ impl Executor for MockExecutor {
_output_policy: &CommandOutputPolicy,
) -> Result<Measurement> {
#[cfg(unix)]
let status = {
let exit_status = {
use std::os::unix::process::ExitStatusExt;
ExitStatus::from_raw(0)
};
#[cfg(windows)]
let status = {
let exit_status = {
use std::os::windows::process::ExitStatusExt;
ExitStatus::from_raw(0)
};
Ok(Measurement {
time_real: Self::extract_time(command.get_command_line()),
time_wall_clock: Self::extract_time(command.get_command_line()),
time_user: 0.0,
time_system: 0.0,
memory_usage_byte: 0,
status,
peak_memory_usage: 0,
exit_status,
})
}
+3 -3
View File
@@ -6,7 +6,7 @@ use crate::util::units::Second;
#[derive(Debug, Default, Copy, Clone)]
pub struct Measurement {
/// Wall clock time
pub time_real: Second,
pub time_wall_clock: Second,
/// Time spent in user mode
pub time_user: Second,
@@ -15,8 +15,8 @@ pub struct Measurement {
pub time_system: Second,
/// Maximum amount of memory used, in bytes
pub memory_usage_byte: u64,
pub peak_memory_usage: u64,
/// The exit status of the process
pub status: ExitStatus,
pub exit_status: ExitStatus,
}
+15 -13
View File
@@ -241,8 +241,9 @@ impl<'a> Benchmark<'a> {
};
let preparation_result = run_preparation_command()?;
let preparation_overhead =
preparation_result.map_or(0.0, |res| res.time_real + self.executor.time_overhead());
let preparation_overhead = preparation_result.map_or(0.0, |res| {
res.time_wall_clock + self.executor.time_overhead()
});
// Initial timing run
let res = self.executor.run_command_and_measure(
@@ -251,15 +252,16 @@ impl<'a> Benchmark<'a> {
None,
output_policy,
)?;
let success = res.status.success();
let success = res.exit_status.success();
let conclusion_result = run_conclusion_command()?;
let conclusion_overhead =
conclusion_result.map_or(0.0, |res| res.time_real + self.executor.time_overhead());
let conclusion_overhead = conclusion_result.map_or(0.0, |res| {
res.time_wall_clock + self.executor.time_overhead()
});
// Determine number of benchmark runs
let runs_in_min_time = (self.options.min_benchmarking_time
/ (res.time_real
/ (res.time_wall_clock
+ self.executor.time_overhead()
+ preparation_overhead
+ conclusion_overhead)) as u64;
@@ -278,11 +280,11 @@ impl<'a> Benchmark<'a> {
let count_remaining = count - 1;
// Save the first result
times_real.push(res.time_real);
times_real.push(res.time_wall_clock);
times_user.push(res.time_user);
times_system.push(res.time_system);
memory_usage_byte.push(res.memory_usage_byte);
exit_codes.push(extract_exit_code(res.status));
memory_usage_byte.push(res.peak_memory_usage);
exit_codes.push(extract_exit_code(res.exit_status));
all_succeeded = all_succeeded && success;
@@ -313,13 +315,13 @@ impl<'a> Benchmark<'a> {
None,
output_policy,
)?;
let success = res.status.success();
let success = res.exit_status.success();
times_real.push(res.time_real);
times_real.push(res.time_wall_clock);
times_user.push(res.time_user);
times_system.push(res.time_system);
memory_usage_byte.push(res.memory_usage_byte);
exit_codes.push(extract_exit_code(res.status));
memory_usage_byte.push(res.peak_memory_usage);
exit_codes.push(extract_exit_code(res.exit_status));
all_succeeded = all_succeeded && success;
+6 -6
View File
@@ -95,16 +95,16 @@ pub fn execute_and_measure(mut command: Command) -> Result<Measurement> {
discard(output);
}
let status = child.wait()?;
let exit_status = child.wait()?;
let time_real = wallclock_timer.stop();
let (time_user, time_system, memory_usage_byte) = cpu_timer.stop();
let time_wall_clock = wallclock_timer.stop();
let (time_user, time_system, peak_memory_usage) = cpu_timer.stop();
Ok(Measurement {
time_real,
time_wall_clock,
time_user,
time_system,
memory_usage_byte,
status,
peak_memory_usage,
exit_status,
})
}