pub struct Time { /* private fields */ }Expand description
Measure a potentially non contiguous duration of time
Implementations§
Source§impl Time
impl Time
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new Time wrapper suitable for recording elapsed
times for operations.
Sourcepub fn add_elapsed(&self, start: Instant)
pub fn add_elapsed(&self, start: Instant)
Add elapsed nanoseconds since startto self
Sourcepub fn add_duration(&self, duration: Duration)
pub fn add_duration(&self, duration: Duration)
Add duration of time to self
Note: this will always increment the recorded time by at least 1 nanosecond to distinguish between the scenario of no values recorded, in which case the value will be 0, and no measurable amount of time having passed, in which case the value will be small but not 0.
This is based on the assumption that the timing logic in most cases is likely to take at least a nanosecond, and so this is reasonable mechanism to avoid ambiguity, especially on systems with low-resolution monotonic clocks
Sourcepub fn timer(&self) -> ScopedTimerGuard<'_>
pub fn timer(&self) -> ScopedTimerGuard<'_>
return a scoped guard that adds the amount of time elapsed
between its creation and its drop or call to stop to the
underlying metric.
Sourcepub fn timer_with(&self, now: Instant) -> ScopedTimerGuard<'_>
pub fn timer_with(&self, now: Instant) -> ScopedTimerGuard<'_>
Return a scoped guard that adds the amount of time elapsed between the
given instant and its drop (or the call to stop) to the underlying metric
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Time
impl RefUnwindSafe for Time
impl Send for Time
impl Sync for Time
impl Unpin for Time
impl UnwindSafe for Time
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more