Skip to content
Myr

Unify timer names per-context

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

authored by Steve Pentland · committed by sharkdp · parent 9407329 · Browse files · 3 files+10 added−10 removed
This commit

State

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

Diff stats

3 files+10 added−10 removed

  • other:+10 added−10 removed

3 files+10 added−10 removed

modified:src/hyperfine/timer/unix_timer.rs+3 added-3 removed
4 unmodified lines
5use hyperfine::internal::Second;67use std::mem;89pub struct UnixCPUTimer {9pub struct CPUTimer {10 start_cpu: CPUTimes,11}1213impl Timer for UnixCPUTimer {13impl Timer for CPUTimer {14 type Result = (Second, Second);1516 fn start() -> Self {17 UnixCPUTimer {17 CPUTimer {18 start_cpu: get_cpu_times(),19 }20 }21
60 unmodified lines
modified:src/hyperfine/timer/windows_timer.rs+3 added-3 removed
16 unmodified lines
17 fn start(handle: RawHandle) -> Self;18 fn stop(&self) -> Self::Result;19}2021pub struct WindowsCPUTimer {21pub struct CPUTimer {22 handle: RawHandle,23}2425impl WindowsTimer for WindowsCPUTimer {25impl WindowsTimer for CPUTimer {26 type Result = (Second, Second);2728 fn start(handle: RawHandle) -> Self {29 WindowsCPUTimer { handle }29 CPUTimer { handle }30 }3132 fn stop(&self) -> Self::Result {33 let times = get_cpu_times(self.handle);
35 unmodified lines
modified:src/hyperfine/benchmark.rs+4 added-4 removed
301 unmodified lines
302}303304#[cfg(windows)]305fn execute_and_time(command: &str) -> io::Result<ExecuteResult> {306 use hyperfine::timer::windows_timer::{WindowsCPUTimer, WindowsTimer};306 use hyperfine::timer::windows_timer::{CPUTimer, WindowsTimer};307 use std::os::windows::io::AsRawHandle;308309 let mut child = run_shell_command(command)?;310 let timer = WindowsCPUTimer::start(child.as_raw_handle());310 let timer = CPUTimer::start(child.as_raw_handle());311 let status = child.wait()?;312313 let (user_time, system_time) = timer.stop();314 Ok(ExecuteResult {
4 unmodified lines
319}320321#[cfg(not(windows))]322fn execute_and_time(command: &str) -> io::Result<ExecuteResult> {323 use hyperfine::timer::unix_timer::UnixCPUTimer;323 use hyperfine::timer::unix_timer::CPUTimer;324325 let cpu_timer = UnixCPUTimer::start();325 let cpu_timer = CPUTimer::start();326327 let status = run_shell_command(command)?;328329 let (user_time, system_time) = cpu_timer.stop();
7 unmodified lines