#tsc #rdtsc #nanosecond-timing #clock #nanosecond

fastant

A drop-in replacement for std::time::Instant that measures time with high performance and high accuracy powered by Time Stamp Counter (TSC)

4 releases

0.1.11 Nov 25, 2025
0.1.10 Feb 13, 2025
0.1.9 Aug 12, 2024
0.1.8 Aug 12, 2024

#3 in #clock

Download history 73866/week @ 2025-09-01 66686/week @ 2025-09-08 48807/week @ 2025-09-15 145470/week @ 2025-09-22 162660/week @ 2025-09-29 197168/week @ 2025-10-06 169181/week @ 2025-10-13 160533/week @ 2025-10-20 192763/week @ 2025-10-27 199643/week @ 2025-11-03 197261/week @ 2025-11-10 209934/week @ 2025-11-17 90902/week @ 2025-11-24 124734/week @ 2025-12-01 340288/week @ 2025-12-08 55927/week @ 2025-12-15

617,622 downloads per month
Used in 76 crates (5 directly)

MIT license

29KB
437 lines

Fastant

A drop-in replacement for std::time::Instant that measures time with high performance and high accuracy powered by Time Stamp Counter (TSC).

Actions Status Documentation Crates.io LICENSE

Usage

[dependencies]
fastant = "0.1"
fn main() {
    let start = fastant::Instant::now();
    let duration: std::time::Duration = start.elapsed();
}

Motivation

This library is used by a high performance tracing library fastrace. The main purpose is to use Time Stamp Counter (TSC) on x86 processors to measure time at high speed without losing much accuracy.

Platform Support

Currently, only the Linux on x86 or x86_64 is backed by Time Stamp Counter (TSC). On other platforms, Fastant falls back to std::time. If TSC is unstable, it will also fall back to std::time.

If speed is privileged over accuracy when fallback occurs, you can use fallback-coarse feature to use coarse time:

[dependencies]
fastant = { version = "0.1", features = ["fallback-coarse"] }

Dependencies

~37–325KB