Struct ExecutionTime

Source
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

Source

pub fn start() -> Self

Starts a new stopwatch.

This function initializes the timer by recording the current time.

§Returns

A new ExecutionTime instance.

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.