pub fn precise_time_ns() -> u64 {
    return os_precise_time_ns();

    #[cfg(windows)]
    fn os_precise_time_ns() -> u64 {
        let mut ticks_per_s = 0;
        assert_eq!(unsafe {
            libc::QueryPerformanceFrequency(&mut ticks_per_s)
        }, 1);
        let ticks_per_s = if ticks_per_s == 0 {1} else {ticks_per_s};
        let mut ticks = 0;
        assert_eq!(unsafe {
            libc::QueryPerformanceCounter(&mut ticks)
        }, 1);

        return (ticks as u64 * 1000000000) / (ticks_per_s as u64);
    }

    #[cfg(target_os = "macos")]
    fn os_precise_time_ns() -> u64 {
        let time = unsafe { imp::mach_absolute_time() };
        let mut info = libc::mach_timebase_info { numer: 0, denom: 0 };
        unsafe { imp::mach_timebase_info(&mut info); }
        return time * ((info.numer / info.denom) as u64);
    }

    #[cfg(not(windows), not(target_os = "macos"))]
    fn os_precise_time_ns() -> u64 {
        let mut ts = libc::timespec { tv_sec: 0, tv_nsec: 0 };
        unsafe {
            imp::clock_gettime(libc::CLOCK_MONOTONIC, &mut ts);
        }
        return (ts.tv_sec as u64) * 1000000000 + (ts.tv_nsec as u64)
    }
}
/**
 * Returns the current value of a high-resolution performance counter
 * in nanoseconds since an unspecified epoch.
 */
Returns the current value of a high-resolution performance counter
in nanoseconds since an unspecified epoch.
Returns the current value of a high - resolution performance counter in nanoseconds since an unspecified epoch .
pub fn precise_time_ns() -> u64 {
    return os_precise_time_ns();
    #[cfg(windows)]
    fn os_precise_time_ns() -> u64 {
        let mut ticks_per_s = 0;
        assert_eq!(unsafe {
            libc::QueryPerformanceFrequency(&mut ticks_per_s)
        }, 1);
        let ticks_per_s = if ticks_per_s == 0 {1} else {ticks_per_s};
        let mut ticks = 0;
        assert_eq!(unsafe {
            libc::QueryPerformanceCounter(&mut ticks)
        }, 1);
        return (ticks as u64 * 1000000000) / (ticks_per_s as u64);
    }
    #[cfg(target_os = "macos")]
    fn os_precise_time_ns() -> u64 {
        let time = unsafe { imp::mach_absolute_time() };
        let mut info = libc::mach_timebase_info { numer: 0, denom: 0 };
        unsafe { imp::mach_timebase_info(&mut info); }
        return time * ((info.numer / info.denom) as u64);
    }
    #[cfg(not(windows), not(target_os = "macos"))]
    fn os_precise_time_ns() -> u64 {
        let mut ts = libc::timespec { tv_sec: 0, tv_nsec: 0 };
        unsafe {
            imp::clock_gettime(libc::CLOCK_MONOTONIC, &mut ts);
        }
        return (ts.tv_sec as u64) * 1000000000 + (ts.tv_nsec as u64)
    }
}
pub fn precise_time_ns ( ) -> u64 { return os_precise_time_ns ( ) ; # [ cfg ( windows ) ] fn os_precise_time_ns ( ) -> u64 { let mut ticks_per_s = 0 ; assert_eq ! ( unsafe { libc QueryPerformanceFrequency ( mut ticks_per_s ) } 1 ) ; let ticks_per_s = if ticks_per_s == 0 { 1 } else { ticks_per_s } ; let mut ticks = 0 ; assert_eq ! ( unsafe { libc QueryPerformanceCounter ( mut ticks ) } 1 ) ; return ( ticks as u64 * 1000000000 ) / ( ticks_per_s as u64 ) ; } # [ cfg ( target_os " " ) ] fn os_precise_time_ns ( ) -> u64 { let time = unsafe { imp :: mach_absolute_time ( ) } ; let mut info = libc :: mach_timebase_info { numer : 0 , denom : 0 } ; unsafe { imp :: mach_timebase_info ( & mut info ) ; } return time * ( ( info . numer / info . denom ) as u64 ) ; } # [ cfg ( not ( windows ) not ( target_os " " ) ) ] fn os_precise_time_ns ( ) -> u64 { let mut ts = libc :: timespec { tv_sec : 0 , tv_nsec : 0 } ; unsafe { imp :: clock_gettime ( libc :: CLOCK_MONOTONIC , & mut ts ) ; } return ( ts . tv_sec as u64 ) * 1000000000 + ( ts . tv_nsec as u64 ) } }
Returns the current value of a high-resolution performance counter
 in nanoseconds since an unspecified epoch.
Returns the current value of a high - resolution performance counter in nanoseconds since an unspecified epoch .