mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-10-28 16:18:57 +00:00
Unify timer names per-context
This commit is contained in:
1 parent
940732947c
commit
36cc649d13
3 files changed
+10
-10
No files matched your search
@@ -303,11 +303,11 @@ struct ExecuteResult {
|
||||
|
||||
#[cfg(windows)]
|
||||
fn execute_and_time(command: &str) -> io::Result<ExecuteResult> {
|
||||
use hyperfine::timer::windows_timer::{WindowsCPUTimer, WindowsTimer};
|
||||
use hyperfine::timer::windows_timer::{CPUTimer, WindowsTimer};
|
||||
use std::os::windows::io::AsRawHandle;
|
||||
|
||||
let mut child = run_shell_command(command)?;
|
||||
let timer = WindowsCPUTimer::start(child.as_raw_handle());
|
||||
let timer = CPUTimer::start(child.as_raw_handle());
|
||||
let status = child.wait()?;
|
||||
|
||||
let (user_time, system_time) = timer.stop();
|
||||
@@ -320,9 +320,9 @@ fn execute_and_time(command: &str) -> io::Result<ExecuteResult> {
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn execute_and_time(command: &str) -> io::Result<ExecuteResult> {
|
||||
use hyperfine::timer::unix_timer::UnixCPUTimer;
|
||||
use hyperfine::timer::unix_timer::CPUTimer;
|
||||
|
||||
let cpu_timer = UnixCPUTimer::start();
|
||||
let cpu_timer = CPUTimer::start();
|
||||
|
||||
let status = run_shell_command(command)?;
|
||||
|
||||
|
||||
@@ -6,15 +6,15 @@ use hyperfine::internal::Second;
|
||||
|
||||
use std::mem;
|
||||
|
||||
pub struct UnixCPUTimer {
|
||||
pub struct CPUTimer {
|
||||
start_cpu: CPUTimes,
|
||||
}
|
||||
|
||||
impl Timer for UnixCPUTimer {
|
||||
impl Timer for CPUTimer {
|
||||
type Result = (Second, Second);
|
||||
|
||||
fn start() -> Self {
|
||||
UnixCPUTimer {
|
||||
CPUTimer {
|
||||
start_cpu: get_cpu_times(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,15 @@ pub trait WindowsTimer {
|
||||
fn stop(&self) -> Self::Result;
|
||||
}
|
||||
|
||||
pub struct WindowsCPUTimer {
|
||||
pub struct CPUTimer {
|
||||
handle: RawHandle,
|
||||
}
|
||||
|
||||
impl WindowsTimer for WindowsCPUTimer {
|
||||
impl WindowsTimer for CPUTimer {
|
||||
type Result = (Second, Second);
|
||||
|
||||
fn start(handle: RawHandle) -> Self {
|
||||
WindowsCPUTimer { handle }
|
||||
CPUTimer { handle }
|
||||
}
|
||||
|
||||
fn stop(&self) -> Self::Result {
|
||||
|
||||
Reference in new issue
Block a user