clocksource
A Rust library for time and duration types with fixed-size representations, providing coarse (second-resolution) and precise (nanosecond-resolution) variants, plus atomic versions for concurrent use. All types use a single 32-bit or 64-bit integer internally, making them compact and efficient for arithmetic operations.
Getting Started
cargo add clocksource
Usage
use coarse;
use precise;
// Coarse (second-resolution) monotonic instant
let coarse_start = now;
// ... do work ...
let coarse_elapsed: Duration = coarse_start.elapsed;
println!;
// Precise (nanosecond-resolution) monotonic instant
let precise_start = now;
// ... do work ...
let precise_elapsed: Duration = precise_start.elapsed;
println!;
// Unix timestamps
let now = now;
let coarse_now = now;
Links
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.