[][src]Struct cpu_time::ThreadTime

pub struct 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]

impl Copy for ThreadTime[src]

impl Eq for ThreadTime[src]

impl PartialEq<ThreadTime> for ThreadTime[src]

impl Debug for ThreadTime[src]

impl Hash for ThreadTime[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]