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 get_elapsed_time(&self) -> String
pub fn get_elapsed_time(&self) -> String
Calculates the elapsed time since the stopwatch was started.
This method calculates the elapsed time, formats it into a readable string.
The output format depends on whether the elapsed time is less than or greater than 60 seconds.
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.