fastant

Crates.iofastant
lib.rsfastant
version0.1.9
sourcesrc
created_at2024-08-12 15:52:55.213236
updated_at2024-08-12 16:01:07.968743
descriptionA drop-in replacement for `std::time::Instant` that measures time with high performance and high accuracy powered by Time Stamp Counter (TSC).
homepagehttps://github.com/fast/fastant
repositoryhttps://github.com/fast/fastant
max_upload_size
id1334643
size41,413
tison (tisonkun)

documentation

https://docs.rs/fastant

README

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"] }
Commit count: 0

cargo fmt