#timer #time #duration

eggtimer

Timer types for measuring time in a program in different ways

8 releases (4 breaking)

0.5.0 Aug 29, 2020
0.4.0 Mar 20, 2019
0.3.2 Jan 19, 2019
0.3.1 Nov 13, 2018
0.1.1 Nov 13, 2018

#47 in Date and time

Download history 1/week @ 2020-05-20 15/week @ 2020-05-27 22/week @ 2020-06-03 11/week @ 2020-06-17 3/week @ 2020-06-24 39/week @ 2020-07-01 24/week @ 2020-07-08 7/week @ 2020-07-15 32/week @ 2020-07-22 3/week @ 2020-08-05 25/week @ 2020-08-12 10/week @ 2020-08-19 20/week @ 2020-08-26 25/week @ 2020-09-02

59 downloads per month

MIT license

17KB
353 lines

Description

This crate provides Rust timer types for measuring time in a program in different ways.

  • Timer is a timer that counts up and knows how much time has passed since it was started.
  • EggTimer is a timer that counts down from its set Duration and knows how much time it has left.
  • Stopwatch is a timer that counts up and can be paused and resumed.

In addition to the timer types, a collection type, TimedList, is provided, which associates each element with a Duration and only retains elements whose Duration has not elapsed.

Usage

To use this crate, add this to your Cargo.toml:

[dependencies]
eggtimer = "0.3.2"

Example

use eggtimer::Timer;

fn computation() {
    // Do some computation that takes some time.
}

fn main() {
    // Start the timer
    let timer = Timer::start();

    // Do a computation
    computation();

    // Check how long it took
    let elapsed = timer.elapsed();
    println!("The computation took {} seconds.", elapsed);
}

No runtime deps