sparkles-core 0.1.8

Core crate for sparkles
Documentation
#[cfg(target_arch="x86")]
use core::arch::x86 as arch;
#[cfg(target_arch="x86_64")]
use core::arch::x86_64 as arch;
use crate::timestamp::TimestampProvider;

pub struct X86Timestamp;

impl TimestampProvider for X86Timestamp {
    type TimestampType = u64;

    #[inline(always)]
    fn now() -> Self::TimestampType {
        unsafe {
            #[cfg(feature = "accurate-timestamps-x86")]
            let v = arch::__rdtscp(&mut 0);
            #[cfg(not(feature = "accurate-timestamps-x86"))]
            let v = arch::_rdtsc();

            v
        }
    }
}