2021-08-24 21:36:37 +02:00
|
|
|
use std::process::Child;
|
2018-02-05 18:22:59 -05:00
|
|
|
|
2021-08-24 21:48:10 +02:00
|
|
|
use crate::units::Second;
|
|
|
|
|
|
2018-02-02 17:28:52 +01:00
|
|
|
pub mod wallclocktimer;
|
2018-02-05 18:22:59 -05:00
|
|
|
|
2021-08-24 21:36:37 +02:00
|
|
|
#[cfg(windows)]
|
|
|
|
|
mod windows_timer;
|
|
|
|
|
#[cfg(windows)]
|
|
|
|
|
pub use self::windows_timer::get_cpu_timer;
|
2019-05-07 11:55:38 +02:00
|
|
|
|
2021-08-24 21:36:37 +02:00
|
|
|
#[cfg(not(windows))]
|
|
|
|
|
mod unix_timer;
|
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
|
pub use self::unix_timer::get_cpu_timer;
|
2018-02-07 19:03:52 -05:00
|
|
|
|
|
|
|
|
/// Defines start functionality of a timer.
|
|
|
|
|
pub trait TimerStart {
|
2018-02-02 17:28:52 +01:00
|
|
|
fn start() -> Self;
|
2018-02-07 19:03:52 -05:00
|
|
|
fn start_for_process(process: &Child) -> Self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Defines stop functionality of a timer.
|
|
|
|
|
pub trait TimerStop {
|
|
|
|
|
type Result;
|
2018-02-02 17:28:52 +01:00
|
|
|
fn stop(&self) -> Self::Result;
|
|
|
|
|
}
|
2021-08-24 21:48:10 +02:00
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone)]
|
|
|
|
|
pub struct CPUTimes {
|
|
|
|
|
/// Total amount of time spent executing in user mode
|
|
|
|
|
pub user_usec: i64,
|
|
|
|
|
|
|
|
|
|
/// Total amount of time spent executing in kernel mode
|
|
|
|
|
pub system_usec: i64,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone)]
|
|
|
|
|
pub struct CPUInterval {
|
|
|
|
|
/// Total amount of time spent executing in user mode
|
|
|
|
|
pub user: Second,
|
|
|
|
|
|
|
|
|
|
/// Total amount of time spent executing in kernel mode
|
|
|
|
|
pub system: Second,
|
|
|
|
|
}
|