Crates.io | performance-mark |
lib.rs | performance-mark |
version | 0.3.0 |
source | src |
created_at | 2023-04-18 17:25:50.176417 |
updated_at | 2023-10-18 00:35:31.345079 |
description | A utility library for marking events and durations for performance-tracking purposes. |
homepage | |
repository | https://github.com/candlecorp/wick |
max_upload_size | |
id | 842643 |
size | 27,163 |
This library is for marking periods of time and events in those periods.
use performance_mark::Performance;
use std::thread::sleep;
use std::time::Duration;
fn main() {
let wait = Duration::from_millis(100);
let mut perf = Performance::new();
perf.mark("start");
sleep(wait);
perf.start("middle");
sleep(wait);
perf.end("middle");
sleep(wait);
perf.mark("end");
println!("{:?}", perf.events());
assert_eq!(perf.events().len(), 2);
assert!(perf.events()[0] < perf.events()[1]);
assert_eq!(perf.periods().len(), 1);
assert!(perf.periods().get("middle").unwrap().duration() >= wait);
}