julid-rs/examples/benchmark.rs

24 lines
513 B
Rust
Raw Normal View History

2023-07-25 19:04:38 +00:00
use std::time::Instant;
use julid::Julid;
2023-07-25 19:04:38 +00:00
fn main() {
let mut v = Vec::with_capacity(2000);
let start = Instant::now();
for _ in 0..2000 {
v.push(Julid::new());
}
let end = Instant::now();
let dur = (end - start).as_micros();
for id in v.iter() {
println!(
"{id}: created_at {}; counter: {}; sortable: {}",
id.created_at(),
2023-07-25 19:04:38 +00:00
id.counter(),
id.sortable()
);
}
println!("2000 IDs generated in {dur}us");
}