1#[cfg(feature = "time")]
4fn main() {
5 use bento_kit::time::{format_now_local, format_now_utc, now_millis, TimeUse};
6 use std::thread::sleep;
7 use std::time::Duration;
8
9 println!("now (utc) = {}", format_now_utc("%Y-%m-%d %H:%M:%S"));
10 println!("now (local) = {}", format_now_local("%Y-%m-%d %H:%M:%S %Z"));
11 println!("now millis = {}", now_millis());
12
13 let mut t = TimeUse::new();
14
15 t.start(Some("connect"));
16 sleep(Duration::from_millis(20));
17 println!("connect = {:?}", t.stop(Some("connect")));
18
19 t.start(Some("query"));
20 sleep(Duration::from_millis(40));
21 println!("query = {:?}", t.stop(Some("query")));
22
23 sleep(Duration::from_millis(10));
24 println!("total = {:?}", t.stop(None));
25}
26
27#[cfg(not(feature = "time"))]
28fn main() {
29 eprintln!("Run with --features time");
30}