55 const f64 round_to_units = 100e5;
57 f64 time_now, time_start, time_limit, freq;
61 time_limit = time_now + sample_time;
63 while (time_now < time_limit)
67 freq = (t[1] - t[0]) / (time_now - time_start);
69 freq = ifreq * round_to_units;
85 #if defined(__aarch64__) 90 fd = open (
"/proc/cpuinfo", 0);
99 if (
unformat (&input,
"cpu MHz : %f", &cpu_freq))
101 else if (
unformat (&input,
"timebase : %f", &ppc_timebase))
112 if (ppc_timebase != 0)
113 cpu_freq = ppc_timebase;
129 fd = open (
"/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", 0);
147 if (clib_cpu_supports_invariant_tsc ())
150 #if defined (__aarch64__) 152 asm volatile (
"mrs %0, CNTFRQ_EL0":
"=r" (tsc));
177 memset (c, 0,
sizeof (c[0]));
197 f64 round_units = 100e5;
209 dtr_max = dtr_max > 8.0 ? dtr_max : 8.0;
211 if (dtr <= 0.0 || dtr > dtr_max)
static u64 clib_cpu_time_now(void)
u32 log2_clocks_per_second
static f64 unix_time_now(void)
static u64 min_log2_u64(u64 x)
u32 log2_clocks_per_frequency_verify
void clib_time_init(clib_time_t *c)
void clib_time_verify_frequency(clib_time_t *c)
static f64 clock_frequency_from_sys_filesystem(void)
f64 os_cpu_clock_frequency(void)
static f64 clock_frequency_from_proc_filesystem(void)
f64 last_verify_reference_time
static word flt_round_nearest(f64 x)
static f64 estimate_clock_frequency(f64 sample_time)