Struct simple_stopwatch::Stopwatch [] [src]

pub struct Stopwatch { /* fields omitted */ }

Simple stopwatch

Methods

impl Stopwatch
[src]

[src]

Create new stopwatch and start timing

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

[src]

Get elapsed time since creation/restart in seconds

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

[src]

Get elapsed time since creation/restart in microseconds

[src]

Get elapsed time since creation/restart in nanoseconds

Trait Implementations

impl Clone for Stopwatch
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Copy for Stopwatch
[src]