| Crates.io | seq-timer |
| lib.rs | seq-timer |
| version | 0.1.0 |
| created_at | 2022-06-29 08:02:08.715278+00 |
| updated_at | 2022-06-29 08:02:08.715278+00 |
| description | A simple timer for sequential events |
| homepage | |
| repository | https://github.com/imbolc/seq-timer |
| max_upload_size | |
| id | 615277 |
| size | 8,437 |
A simple timer for sequential events
use std::{ time::Duration, thread::sleep };
let mut timer = seq_timer::Timer::new();
// starts the first event
timer.start("the first event");
sleep(Duration::from_millis(1));
// finishes the first event and starts the second one
// you can also `.finish()` the current event manually
timer.start("the second event");
sleep(Duration::from_millis(10));
// finishes the last event and prints sorted measurments to stdout:
timer.print();
The output would be similar to:
the second event | 10078204 ns | 88%
the first event | 1265423 ns | 11%
The timer also implements Display, but you must
finish the last event manually in this case: debug!("{}", timer.finish())
We appreciate all kinds of contributions, thank you!
The README.md file isn't meant to be changed directly. It instead generated from the crate's docs
by the cargo-readme command:
cargo install cargo-readmesrc/lib.rs, or wrapping text in README.tplcargo readme > README.mdIf you have rusty-hook installed the changes will apply automatically on commit.
This project is licensed under the MIT license.