pub struct TscTimestamp(pub u64);Expand description
High-precision timestamp using TSC
Tuple Fields§
§0: u64Implementations§
Source§impl TscTimestamp
impl TscTimestamp
Sourcepub fn now() -> Self
pub fn now() -> Self
Read current TSC timestamp.
- x86_64:
RDTSC— bias 0, latency a few cycles. - aarch64:
CNTVCT_EL0(the virtual count register) — same wall-clock semantics as RDTSC but at the system counter frequency (typically 24 MHz on Apple Silicon, exposed viaCNTFRQ_EL0). Callers must pass the righttsc_freq_hztonanos_sincefor portability. - other: fall back to
Instant::now()so the crate still compiles on wasm32 / riscv64 / etc. The returned u64 is nanoseconds since program start, andnanos_sinceshould be called withtsc_freq_hz = 1_000_000_000on these targets.
Sourcepub fn nanos_since(&self, other: TscTimestamp, tsc_freq_hz: u64) -> u64
pub fn nanos_since(&self, other: TscTimestamp, tsc_freq_hz: u64) -> u64
Calculate nanoseconds since another timestamp
Trait Implementations§
Source§impl Clone for TscTimestamp
impl Clone for TscTimestamp
Source§fn clone(&self) -> TscTimestamp
fn clone(&self) -> TscTimestamp
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TscTimestamp
impl Debug for TscTimestamp
Source§impl Ord for TscTimestamp
impl Ord for TscTimestamp
Source§fn cmp(&self, other: &TscTimestamp) -> Ordering
fn cmp(&self, other: &TscTimestamp) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for TscTimestamp
impl PartialEq for TscTimestamp
Source§fn eq(&self, other: &TscTimestamp) -> bool
fn eq(&self, other: &TscTimestamp) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for TscTimestamp
impl PartialOrd for TscTimestamp
impl Copy for TscTimestamp
impl Eq for TscTimestamp
impl StructuralPartialEq for TscTimestamp
Auto Trait Implementations§
impl Freeze for TscTimestamp
impl RefUnwindSafe for TscTimestamp
impl Send for TscTimestamp
impl Sync for TscTimestamp
impl Unpin for TscTimestamp
impl UnsafeUnpin for TscTimestamp
impl UnwindSafe for TscTimestamp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more