1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Portable high-resolution monotonic timer.
//!
//! Wraps [`std::time::Instant`], which is monotonic and thread-safe on all
//! supported platforms, providing an API equivalent to `timefn.h` from the
//! LZ4 reference implementation. The platform-specific backends from the C
//! version (`QueryPerformanceCounter`, `mach_absolute_time`,
//! `clock_gettime`, etc.) are all subsumed by `Instant::now()`.
use Instant;
/// Nanosecond duration type (equivalent to C `Duration_ns` / `unsigned long long`).
pub type DurationNs = u64;
/// Opaque timestamp container. The absolute value is not meaningful;
/// use it only to compute a duration between two measurements.
/// Equivalent to C `TIME_t`.
/// Returns current monotonic timestamp.
/// Equivalent to `TIME_t TIME_getTime(void)`.
/// Returns the nanosecond duration between `clock_start` and `clock_end`.
/// Equivalent to `Duration_ns TIME_span_ns(TIME_t clockStart, TIME_t clockEnd)`.
/// Measures nanoseconds elapsed since `clock_start` (captures current time internally).
/// Equivalent to `Duration_ns TIME_clockSpan_ns(TIME_t clockStart)`.
/// Busy-waits until the clock advances by at least 1 ns.
/// Used before benchmark loops to synchronize with a clock tick.
/// Equivalent to `void TIME_waitForNextTick(void)`.
/// Returns `true` if `get_time()` is safe to use across threads.
/// Rust's `Instant` is always MT-safe, so this always returns `true`.
/// Equivalent to `int TIME_support_MT_measurements(void)` returning 1.