Unify TimingResult/TimerResult/Measurement

This commit is contained in:
David Peter authored and David Peter committed 2026-10-05 15:58:56 +02:00
1 parent f9aa299c0f
commit 42e75c1737
8 files changed
+272 -261

No files matched your search

+4 -15
View File
@@ -16,7 +16,7 @@ use std::os::fd::AsFd;
#[cfg(target_os = "windows")]
use windows_sys::Win32::System::Threading::CREATE_SUSPENDED;
use crate::benchmark::quantity::{Byte, Second};
use crate::benchmark::measurement::Measurement;
use wall_clock_timer::WallClockTimer;
use std::io::Read;
@@ -24,17 +24,6 @@ use std::process::{ChildStdout, Command};
use anyhow::Result;
/// Used to indicate the result of running a command
#[derive(Debug, Copy, Clone)]
pub struct TimerResult {
pub time_wall_clock: Second,
pub time_user: Second,
pub time_system: Second,
pub memory_usage_byte: Byte,
/// The exit status of the process
pub status: ExitStatus,
}
/// Discard the output of a child process.
fn discard(output: ChildStdout) {
const CHUNK_SIZE: usize = 64 << 10;
@@ -93,14 +82,14 @@ pub fn execute_and_measure(mut command: Command) -> Result<Measurement> {
discard(output);
}
let (status, time_user, time_system, memory_usage_byte) = cpu_timer.stop(child)?;
let (exit_status, time_user, time_system, memory_usage_byte) = cpu_timer.stop(child)?;
let time_wall_clock = wallclock_timer.stop();
Ok(TimerResult {
Ok(Measurement {
time_wall_clock,
time_user,
time_system,
peak_memory_usage,
peak_memory_usage: memory_usage_byte,
exit_status,
})
}