[−][src]Struct cpu_time::ThreadTime
CPU Time Used by The Current Thread
This is an opaque type similar to std::time::Instant
.
Use elapsed()
or duration_since()
to get meaningful time deltas.
This type is non-thread-shareable (!Sync, !Send) because otherwise it's
to easy to mess up times from different threads. However, you can freely
send Duration's returned by elapsed()
and duration_since()
.
Methods
impl ThreadTime
[src]
pub fn try_now() -> Result<Self>
[src]
Get current CPU time used by a process process
pub fn now() -> Self
[src]
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).
pub fn try_elapsed(&self) -> Result<Duration>
[src]
Returns the amount of CPU time used by the current thread from the previous timestamp to now.
pub fn elapsed(&self) -> Duration
[src]
Returns the amount of CPU time used from the previous timestamp to now.
Panics
If ThreadTime::now()
panics.
pub fn duration_since(&self, timestamp: ThreadTime) -> Duration
[src]
Returns the amount of CPU time used by the current thread from the previous timestamp.
pub fn as_duration(&self) -> Duration
[src]
Returns the total amount of CPU time used from the program start.
Trait Implementations
impl Clone for ThreadTime
[src]
fn clone(&self) -> ThreadTime
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for ThreadTime
[src]
impl Eq for ThreadTime
[src]
impl PartialEq<ThreadTime> for ThreadTime
[src]
fn eq(&self, other: &ThreadTime) -> bool
[src]
fn ne(&self, other: &ThreadTime) -> bool
[src]
impl Debug for ThreadTime
[src]
impl Hash for ThreadTime
[src]
Auto Trait Implementations
impl !Send for ThreadTime
impl !Sync for ThreadTime
impl Unpin for ThreadTime
impl UnwindSafe for ThreadTime
impl !RefUnwindSafe for ThreadTime
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,