53 const f64 round_to_units = 100e5;
55 f64 time_now, time_start, time_limit, freq;
59 time_limit = time_now + sample_time;
61 while (time_now < time_limit)
65 freq = (t[1] - t[0]) / (time_now - time_start);
67 freq = ifreq * round_to_units;
82 #if defined(__aarch64__) 87 fd = open (
"/proc/cpuinfo", 0);
96 if (
unformat (&input,
"cpu MHz : %f", &cpu_freq))
98 else if (
unformat (&input,
"timebase : %f", &ppc_timebase))
109 if (ppc_timebase != 0)
110 cpu_freq = ppc_timebase;
125 fd = open (
"/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", 0);
162 memset (c, 0,
sizeof (c[0]));
181 f64 round_units = 100e5;
193 dtr_max = dtr_max > 8.0 ? dtr_max : 8.0;
195 if (dtr <= 0.0 || dtr > dtr_max)
always_inline f64 unix_time_now(void)
u32 log2_clocks_per_second
u32 log2_clocks_per_frequency_verify
void clib_time_init(clib_time_t *c)
void clib_time_verify_frequency(clib_time_t *c)
always_inline u64 min_log2_u64(u64 x)
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 f64 estimate_clock_frequency(f64 sample_time)
always_inline word flt_round_nearest(f64 x)
always_inline u64 clib_cpu_time_now(void)