pub struct TimeReporter { /* private fields */ }
Expand description
Collect and report total time spent on set of activities.
TimeReporter
is useful for generating and reporting
time reports: how much time was spend on a given activity.
On drop
or on call to finish
it will report total times
gathered as a tracing
event.
Implementations§
Source§impl TimeReporter
impl TimeReporter
Sourcepub fn new_with_level<S: Into<String>>(name: S, level: Level) -> Self
pub fn new_with_level<S: Into<String>>(name: S, level: Level) -> Self
Create a new TimeReporter
with a specified level.
Sourcepub fn start(&mut self, key: &'static str)
pub fn start(&mut self, key: &'static str)
Start counting time for a state named “key”.
If this TimeReporter
was already counting time
for another state, it will end counting time for it
before starting a new one.
Sourcepub fn start_with<F, R>(&mut self, key: &'static str, f: F) -> Rwhere
F: FnOnce() -> R,
pub fn start_with<F, R>(&mut self, key: &'static str, f: F) -> Rwhere
F: FnOnce() -> R,
Start counting time and execute a function f
.
This is handy syntax for if let
or while let
expressions
where it would be inconvenient to add a standalone start
call.
Trait Implementations§
Source§impl Clone for TimeReporter
impl Clone for TimeReporter
Source§fn clone(&self) -> TimeReporter
fn clone(&self) -> TimeReporter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for TimeReporter
impl Debug for TimeReporter
Source§impl<'a> Display for TimeReporter
impl<'a> Display for TimeReporter
Source§impl Drop for TimeReporter
impl Drop for TimeReporter
Source§impl PartialEq for TimeReporter
impl PartialEq for TimeReporter
impl Eq for TimeReporter
impl StructuralPartialEq for TimeReporter
Auto Trait Implementations§
impl Freeze for TimeReporter
impl RefUnwindSafe for TimeReporter
impl Send for TimeReporter
impl Sync for TimeReporter
impl Unpin for TimeReporter
impl UnwindSafe for TimeReporter
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.