pub struct ThreadTime(/* private fields */);Expand description
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().
Implementations§
Source§impl ThreadTime
impl ThreadTime
Sourcepub fn now() -> Self
pub fn now() -> Self
§Panics
If GetThreadTimes fails. This may happen, for instance, in case of insufficient permissions.
See this MSDN page for details. If you prefer to handle such errors, consider
using try_now.
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 ThreadTime::now() panics.
Sourcepub fn duration_since(&self, timestamp: ThreadTime) -> Duration
pub fn duration_since(&self, timestamp: ThreadTime) -> Duration
Returns the amount of CPU time used by the current thread 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 ThreadTime
impl Clone for ThreadTime
Source§fn clone(&self) -> ThreadTime
fn clone(&self) -> ThreadTime
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more