[v1.05] Add support for frequency measurement (both x86 and ARM) (branch measure-freq #220)

This commit is contained in:
Dr-Noob
2024-07-05 08:40:46 +01:00
parent b019256515
commit 9212f19de1
5 changed files with 181 additions and 2 deletions

View File

@@ -8,6 +8,7 @@
#ifdef __linux__
#include <sys/auxv.h>
#include <asm/hwcap.h>
#include "../common/freq.h"
#elif defined __APPLE__ || __MACH__
#include "sysctl.h"
#endif
@@ -41,6 +42,12 @@ struct frequency* get_frequency_info(uint32_t core) {
freq->base = UNKNOWN_DATA;
freq->max = get_max_freq_from_file(core);
#ifdef __linux__
if (freq->max == UNKNOWN_DATA) {
printWarn("Unable to find max frequency from udev, measuring CPU frequency");
freq->max = measure_max_frequency(core);
}
#endif
return freq;
}