pub struct Stopwatch { /* private fields */ }Expand description
Simple stopwatch
Implementations§
Source§impl Stopwatch
impl Stopwatch
Sourcepub fn restart(&mut self)
pub fn restart(&mut self)
Restart timing from current time
§Examples
use simple_stopwatch::Stopwatch;
use std::time::Duration;
fn main() {
let mut sw = Stopwatch::start_new();
// emulate some work
std::thread::sleep(Duration::from_millis(1000));
sw.restart();
let ms = sw.ms();
assert!( ms < 1f32, "After restart, timer value is small" );
}Sourcepub fn ms(&self) -> f32
pub fn ms(&self) -> f32
Get elapsed time since creation/restart in milliseconds
§Examples
use simple_stopwatch::Stopwatch;
use std::time::Duration;
fn main() {
let mut sw = Stopwatch::start_new();
// emulate some work
std::thread::sleep(Duration::from_millis(10));
// measure elapsed time
let ms = sw.ms();
assert!( ms >= 10f32 );
}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