Struct cpu_time::ProcessTime
source · pub struct ProcessTime(_);
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 now() -> Self
pub fn now() -> Self
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>
pub fn try_elapsed(&self) -> Result<Duration>
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: Self) -> Duration
pub fn duration_since(&self, timestamp: Self) -> 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
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ProcessTime
impl Debug for ProcessTime
source§impl Hash for ProcessTime
impl Hash for ProcessTime
source§impl PartialEq<ProcessTime> for ProcessTime
impl PartialEq<ProcessTime> for ProcessTime
source§fn eq(&self, other: &ProcessTime) -> bool
fn eq(&self, other: &ProcessTime) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Copy for ProcessTime
impl Eq for ProcessTime
impl StructuralEq for ProcessTime
impl StructuralPartialEq for ProcessTime
Auto Trait Implementations§
impl RefUnwindSafe for ProcessTime
impl Send for ProcessTime
impl Sync for ProcessTime
impl Unpin for ProcessTime
impl UnwindSafe for ProcessTime
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more