pub struct ExecutionTimer<T>{
pub start: Instant,
/* private fields */
}
Expand description
A timer to measure the elapsed time of code block.
This struct holding a start time. While it get dropped, it will log the elapsed time.
§Example
use subalfred_util::ExecutionTimer;
// Must give a name to the timer, otherwise it will be dropped immediately.
let _t = ExecutionTimer::init(|start| {
tracing::trace!("`example` takes `{}` secs", start.elapsed().as_secs_f64())
});
Fields§
§start: Instant
Start time.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for ExecutionTimer<T>where
T: Freeze,
impl<T> RefUnwindSafe for ExecutionTimer<T>where
T: RefUnwindSafe,
impl<T> Send for ExecutionTimer<T>where
T: Send,
impl<T> Sync for ExecutionTimer<T>where
T: Sync,
impl<T> Unpin for ExecutionTimer<T>where
T: Unpin,
impl<T> UnwindSafe for ExecutionTimer<T>where
T: UnwindSafe,
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