pub struct Stopwatch { /* private fields */ }Expand description
A stopwatch for measuring elapsed time with lap support.
§Example
ⓘ
use fastmcp_rust::testing::prelude::*;
let mut stopwatch = Stopwatch::new();
// Do first operation
stopwatch.lap("operation_1");
// Do second operation
stopwatch.lap("operation_2");
println!("Total time: {:?}", stopwatch.elapsed());
for (name, duration) in stopwatch.laps() {
println!("{}: {:?}", name, duration);
}Implementations§
Source§impl Stopwatch
impl Stopwatch
Sourcepub fn lap(&mut self, name: impl Into<String>)
pub fn lap(&mut self, name: impl Into<String>)
Records a lap with the given name.
The duration is measured from the last lap (or start if no laps).
Sourcepub fn since_last_lap(&self) -> Duration
pub fn since_last_lap(&self) -> Duration
Returns the time since the last lap (or start if no laps).
Sourcepub fn get_lap(&self, name: &str) -> Option<Duration>
pub fn get_lap(&self, name: &str) -> Option<Duration>
Returns the lap with the given name, if it exists.
Sourcepub fn total_lap_time(&self) -> Duration
pub fn total_lap_time(&self) -> Duration
Returns the sum of all lap durations.
Sourcepub fn stats(&self) -> TimingStats
pub fn stats(&self) -> TimingStats
Returns timing statistics.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Stopwatch
impl RefUnwindSafe for Stopwatch
impl Send for Stopwatch
impl Sync for Stopwatch
impl Unpin for Stopwatch
impl UnwindSafe for Stopwatch
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).