Struct aleo_std_timer::Timer
source · [−]pub struct Timer<'name> { /* private fields */ }
Expand description
When this struct is dropped, it logs a message stating its name and how long the execution time was. Can be used to time functions or other critical areas.
Implementations
sourceimpl<'name> Timer<'name>
impl<'name> Timer<'name>
sourcepub fn new(
file: &'static str,
module_path: &'static str,
line: u32,
name: &'name str,
extra_info: Option<String>
) -> Option<Self>
pub fn new(
file: &'static str,
module_path: &'static str,
line: u32,
name: &'name str,
extra_info: Option<String>
) -> Option<Self>
Constructs a new Timer
that prints a ‘Start’ and a ‘Finish’ message.
This method is not usually called directly, use the timer!
macro instead.
sourcepub fn elapsed(&self, elapsed: Duration) -> String
pub fn elapsed(&self, elapsed: Duration) -> String
Returns how long the timer has been running for.
sourcepub fn elapsed_colored(&self, elapsed: Duration) -> ColoredString
pub fn elapsed_colored(&self, elapsed: Duration) -> ColoredString
Returns how long the timer has been running for.
sourcepub fn lap(&self, args: Option<Arguments<'_>>)
pub fn lap(&self, args: Option<Arguments<'_>>)
Outputs a log message with a target of ‘Lap’ showing the current elapsed time, but does not
stop the timer. This method can be called multiple times.
The message can include further information via a format_args!
approach.
This method is usually not called directly, it is easier to use the lap!
macro.
sourcepub fn finish(&self, args: Option<Arguments<'_>>)
pub fn finish(&self, args: Option<Arguments<'_>>)
Outputs a log message with a target of ‘Finish’ and suppresses the normal message
that is output when the timer is dropped. The message can include further format_args!
information. This method is normally called using the finish!
macro. Calling
finish()
again will have no effect.
Trait Implementations
Auto Trait Implementations
impl<'name> !RefUnwindSafe for Timer<'name>
impl<'name> !Send for Timer<'name>
impl<'name> !Sync for Timer<'name>
impl<'name> Unpin for Timer<'name>
impl<'name> !UnwindSafe for Timer<'name>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more