sparkles_core/timestamp/
x86.rs

1#[cfg(target_arch="x86")]
2use core::arch::x86 as arch;
3#[cfg(target_arch="x86_64")]
4use core::arch::x86_64 as arch;
5use crate::timestamp::TimestampProvider;
6
7pub struct X86Timestamp;
8
9impl TimestampProvider for X86Timestamp {
10    type TimestampType = u64;
11
12    #[inline(always)]
13    fn now() -> Self::TimestampType {
14        unsafe {
15            #[cfg(feature = "accurate-timestamps-x86")]
16            let v = arch::__rdtscp(&mut 0);
17            #[cfg(not(feature = "accurate-timestamps-x86"))]
18            let v = arch::_rdtsc();
19
20            v
21        }
22    }
23}