Expand description
Temporal quantification that takes into account the time a system spent suspended.
Note: Some systems like FreeBSD and AIX don’t support CLOCK_BOOTIME. For compatibility CLOCK_MONOTONIC is used as a fallback.
Examples
Using Instant to calculate how long a function took to run:
ⓘ
let now = Instant::now();
// Calling a slow function, it may take a while
slow_function();
let elapsed_time = now.elapsed();
println!("Running slow_function() took {} seconds.", elapsed_time.as_secs());Structs
- A
Durationtype to represent a span of time, typically used for system timeouts. - A measurement of a suspend-aware monotonically nondecreasing clock. Opaque and useful only with
Duration.