moniclock 0.1.0

Monotonic clock
Documentation
  • Coverage
  • 100%
    4 out of 4 items documented1 out of 4 items with examples
  • Size
  • Source code size: 8.29 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.45 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • stephaneyfx/moniclock
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • stephaneyfx

Crate Docs MIT license

Defines a monotonic clock whose values are instances of Duration.

Why not std::time::Instant?

Instant is opaque and cannot be serialized.

Example

let mut clock = moniclock::Clock::new();
let t0 = clock.elapsed();
let sleep_duration = std::time::Duration::from_millis(100);
std::thread::sleep(sleep_duration);
let t1 = clock.elapsed();
assert!(t1 - t0 >= sleep_duration);