Struct simple_stopwatch::Stopwatch
[−]
[src]
pub struct Stopwatch { /* fields omitted */ }
Simple stopwatch
Methods
impl Stopwatch
[src]
fn start_new() -> Stopwatch
[src]
Create new stopwatch and start timing
fn restart(&mut self)
[src]
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" ); }
fn s(&self) -> f32
[src]
Get elapsed time since creation/restart in seconds
fn ms(&self) -> f32
[src]
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 ); }
fn us(&self) -> f32
[src]
Get elapsed time since creation/restart in microseconds
fn ns(&self) -> f32
[src]
Get elapsed time since creation/restart in nanoseconds
Trait Implementations
impl Clone for Stopwatch
[src]
fn clone(&self) -> Stopwatch
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more