#benchmark #stopwatch #features #suspend-resume

stopwatch-rs

A stopwatch implementation with suspend/resume feature

1 unstable release

0.1.0 Jul 22, 2022

#26 in #stopwatch

Download history 12/week @ 2024-04-01

71 downloads per month

MIT license

7KB
121 lines

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

Dependencies

~0.8–2.5MB
~43K SLoC