54 const f64 round_to_units = 100e5;
56 f64 time_now, time_start, time_limit, freq;
60 time_limit = time_now + sample_time;
62 while (time_now < time_limit)
66 freq = (t[1] - t[0]) / (time_now - time_start);
68 freq = ifreq * round_to_units;
84 #if defined(__aarch64__) 89 fd = open (
"/proc/cpuinfo", 0);
98 if (
unformat (&input,
"cpu MHz : %f", &cpu_freq))
100 else if (
unformat (&input,
"timebase : %f", &ppc_timebase))
111 if (ppc_timebase != 0)
112 cpu_freq = ppc_timebase;
128 fd = open (
"/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", 0);
167 memset (c, 0,
sizeof (c[0]));
187 f64 round_units = 100e5;
199 dtr_max = dtr_max > 8.0 ? dtr_max : 8.0;
201 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)