pub struct Timer { /* private fields */ }Expand description
Timer for measuring execution time
Implementations§
Source§impl Timer
impl Timer
Sourcepub fn stop(&mut self) -> UtilsResult<Duration>
pub fn stop(&mut self) -> UtilsResult<Duration>
Stop timing and return elapsed duration
Sourcepub fn stop_and_store(&mut self, label: String) -> UtilsResult<Duration>
pub fn stop_and_store(&mut self, label: String) -> UtilsResult<Duration>
Stop timing and store result with a label
Sourcepub fn time<F, R>(&mut self, f: F) -> (R, Duration)where
F: FnOnce() -> R,
pub fn time<F, R>(&mut self, f: F) -> (R, Duration)where
F: FnOnce() -> R,
Time a closure and return the result and duration
Sourcepub fn time_and_store<F, R>(&mut self, label: String, f: F) -> Rwhere
F: FnOnce() -> R,
pub fn time_and_store<F, R>(&mut self, label: String, f: F) -> Rwhere
F: FnOnce() -> R,
Time a closure, store the result with a label, and return the result
Sourcepub fn measurements(&self) -> &HashMap<String, Duration>
pub fn measurements(&self) -> &HashMap<String, Duration>
Get all measurements
Sourcepub fn get_measurement(&self, label: &str) -> Option<Duration>
pub fn get_measurement(&self, label: &str) -> Option<Duration>
Get a specific measurement
Sourcepub fn summary(&self) -> TimerSummary
pub fn summary(&self) -> TimerSummary
Get summary statistics
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Timer
impl RefUnwindSafe for Timer
impl Send for Timer
impl Sync for Timer
impl Unpin for Timer
impl UnwindSafe for Timer
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
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>
Converts
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>
Converts
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