pub struct ProcessTime(/* private fields */);Expand description
CPU Time Used by The Whole Process
This is an opaque type similar to std::time::Instant.
Use elapsed() or duration_since() to get meaningful time deltas.
Implementations§
Source§impl ProcessTime
impl ProcessTime
Sourcepub fn try_now() -> Result<ProcessTime, Error>
pub fn try_now() -> Result<ProcessTime, Error>
Get current CPU time used by a process process
Sourcepub fn now() -> ProcessTime
pub fn now() -> ProcessTime
Get current CPU time used by a process
§Panics
If CLOCK_THREAD_CPUTIME_ID is not supported by the kernel.
On Linux, it was added in version 2.6.12 (year 2005).
On OpenBSD & FreeBSD support was added in 2013.
On MacOS, clock_gettime was not supported until Sierra (2016).
Sourcepub fn try_elapsed(&self) -> Result<Duration, Error>
pub fn try_elapsed(&self) -> Result<Duration, Error>
Returns the amount of CPU time used from the previous timestamp to now.
Sourcepub fn elapsed(&self) -> Duration
pub fn elapsed(&self) -> Duration
Returns the amount of CPU time used from the previous timestamp to now.
§Panics
If ProcessTime::now() panics.
Sourcepub fn duration_since(&self, timestamp: ProcessTime) -> Duration
pub fn duration_since(&self, timestamp: ProcessTime) -> Duration
Returns the amount of CPU time used from the previous timestamp.
Sourcepub fn as_duration(&self) -> Duration
pub fn as_duration(&self) -> Duration
Returns the total amount of CPU time used from the program start.
Trait Implementations§
Source§impl Clone for ProcessTime
impl Clone for ProcessTime
Source§fn clone(&self) -> ProcessTime
fn clone(&self) -> ProcessTime
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more