| Crates.io | stopwatch-rs |
| lib.rs | stopwatch-rs |
| version | 0.1.0 |
| created_at | 2022-07-22 08:17:39.702425+00 |
| updated_at | 2022-07-22 08:17:39.702425+00 |
| description | A stopwatch implementation with suspend/resume feature. |
| homepage | |
| repository | https://github.com/akiradeveloper/stopwatch-rs |
| max_upload_size | |
| id | 630618 |
| size | 7,654 |
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.
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