[][src]Struct simple_stopwatch::Stopwatch

pub struct Stopwatch { /* fields omitted */ }

Simple stopwatch

Methods

impl Stopwatch[src]

pub fn start_new() -> Stopwatch[src]

Create new stopwatch and start timing

pub 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" );
}

pub fn s(&self) -> f32[src]

Get elapsed time since creation/restart in seconds

pub 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 );
}

pub fn us(&self) -> f32[src]

Get elapsed time since creation/restart in microseconds

pub fn ns(&self) -> f32[src]

Get elapsed time since creation/restart in nanoseconds

Trait Implementations

impl Clone for Stopwatch[src]

impl Copy for Stopwatch[src]

Auto Trait Implementations

impl Send for Stopwatch

impl Unpin for Stopwatch

impl Sync for Stopwatch

impl UnwindSafe for Stopwatch

impl RefUnwindSafe for Stopwatch

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]