- Instant
Instant sleep Duration
examples/datetime/sleep-duration/src/main.rs
fn main() { let start = std::time::Instant::now(); println!("{:?}", start); std::thread::sleep(std::time::Duration::from_secs(1)); let end = std::time::Instant::now(); println!("{:?}", end); let elapsed = end - start; println!("{:?}", elapsed); println!("{:?}", start.elapsed()); }
Instant { tv_sec: 5093638, tv_nsec: 944727638 } Instant { tv_sec: 5093639, tv_nsec: 944974927 } 1.000247289s 1.000311683s