From 36cc649d13c0000cbfdb025fe3ca4eaa1000ef03 Mon Sep 17 00:00:00 2001 From: Steve Pentland Date: Mon, 5 Feb 2018 18:36:57 -0500 Subject: [PATCH] Unify timer names per-context --- src/hyperfine/benchmark.rs | 8 ++++---- src/hyperfine/timer/unix_timer.rs | 6 +++--- src/hyperfine/timer/windows_timer.rs | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/hyperfine/benchmark.rs b/src/hyperfine/benchmark.rs index b3ca8a6..668336c 100644 --- a/src/hyperfine/benchmark.rs +++ b/src/hyperfine/benchmark.rs @@ -303,11 +303,11 @@ struct ExecuteResult { #[cfg(windows)] fn execute_and_time(command: &str) -> io::Result { - 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 { #[cfg(not(windows))] fn execute_and_time(command: &str) -> io::Result { - 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)?; diff --git a/src/hyperfine/timer/unix_timer.rs b/src/hyperfine/timer/unix_timer.rs index 7cde806..e36d456 100644 --- a/src/hyperfine/timer/unix_timer.rs +++ b/src/hyperfine/timer/unix_timer.rs @@ -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(), } } diff --git a/src/hyperfine/timer/windows_timer.rs b/src/hyperfine/timer/windows_timer.rs index 025352c..2fbfa13 100644 --- a/src/hyperfine/timer/windows_timer.rs +++ b/src/hyperfine/timer/windows_timer.rs @@ -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 {