stopwatch-rs

Crates.iostopwatch-rs
lib.rsstopwatch-rs
version0.1.0
created_at2022-07-22 08:17:39.702425+00
updated_at2022-07-22 08:17:39.702425+00
descriptionA stopwatch implementation with suspend/resume feature.
homepage
repositoryhttps://github.com/akiradeveloper/stopwatch-rs
max_upload_size
id630618
size7,654
Akira Hayakawa (akiradeveloper)

documentation

README

stopwatch-rs

You often need a stopwatch to embed performance measuremet in the production code. This library implements a stopwatch just like the real one which equips suspend/resume functionality, which helps to skip code that shouldn't be included in the measurement.

The stopwatch uses quanta library there it can be built for WASM target.

Example

let mut sw = stopwatch_rs::StopWatch::start();
sleep(Duration::from_secs(1));
println!("{}", sw.split()); // split=1s, lap=1s
sw.suspend();
sleep(Duration::from_secs(2));
sw.resume();
sleep(Duration::from_secs(4));
println!("{}", sw.split()); // split=5s, lap=4s
Commit count: 7

cargo fmt