pub struct ExecutionTime { /* private fields */ }
Expand description
Measures the execution time of a code block.
This struct provides methods to start a timer and print the elapsed time in a user-friendly format.
Implementations§
Source§impl ExecutionTime
impl ExecutionTime
Sourcepub fn start() -> Self
pub fn start() -> Self
Starts a new stopwatch.
This function initializes the timer by recording the current time.
§Returns
A new ExecutionTime
instance.
Sourcepub fn print_elapsed_time(&self)
pub fn print_elapsed_time(&self)
Calculates and prints the elapsed time since the stopwatch was started.
This method calculates the elapsed time, formats it into a readable string, and prints it to the console. The output format depends on whether the elapsed time is less than or greater than 60 seconds.
Auto Trait Implementations§
impl Freeze for ExecutionTime
impl RefUnwindSafe for ExecutionTime
impl Send for ExecutionTime
impl Sync for ExecutionTime
impl Unpin for ExecutionTime
impl UnwindSafe for ExecutionTime
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