#monotonic #duration

boot-time

Monotonic time that takes into account time a system was suspended (if the system supports this)

2 releases

0.1.2 Sep 26, 2023
0.1.1 Sep 25, 2023
0.1.0 Sep 25, 2023

#11 in #monotonic

Download history 746/week @ 2025-08-17 687/week @ 2025-08-24 525/week @ 2025-08-31 905/week @ 2025-09-07 1267/week @ 2025-09-14 1400/week @ 2025-09-21 1011/week @ 2025-09-28 873/week @ 2025-10-05 930/week @ 2025-10-12 1674/week @ 2025-10-19 2145/week @ 2025-10-26 2026/week @ 2025-11-02 2572/week @ 2025-11-09 2041/week @ 2025-11-16 2905/week @ 2025-11-23 3044/week @ 2025-11-30

10,605 downloads per month
Used in completeio

MIT license

33KB
556 lines

Temporal quantification that takes into account the time a system spent suspended.

Note: Some systems like FreeBSD, DragonFlyBSD, NetBSD, AIX, Fuchsia, Emscripten don't support CLOCK_BOOTIME.

For compatibility CLOCK_MONOTONIC is used as a fallback.

Windows QueryPerformanceCounter includes suspended time. So for Windows and unsupported platforms std::time::Instant is just reexported.

Examples

Using Instant to calculate how long a function took to run:

use boot_time::Instant;

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());

Boot time

Crates.io Docs.rs License

This library reimplements std::time::Instant to use suspend-aware monotonic time if target system supports it. Otherwise is uses monotonic time or reexports std::time::Instant.

Dependencies

~47KB