diff options
author | Erik Kundiman <erik@megapahit.org> | 2023-12-31 20:17:04 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2023-12-31 20:17:04 +0800 |
commit | 39850d709889ce38b884b939166e5a40f38c82eb (patch) | |
tree | a8451e867835d7409a982878b8cf2a79936f3d9b /indra/llcommon/llprocessor.cpp | |
parent | b29e14eca719e5bea9f6b2d6ca9a63bf69528b8e (diff) |
tbfreq x clockrate.hz only when cpufrequency is 0
Just maybe M3 implements cpufrequency, which should be more accurate
than the alternative (different results on my Intel Mac).
Diffstat (limited to 'indra/llcommon/llprocessor.cpp')
-rw-r--r-- | indra/llcommon/llprocessor.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index da49c31558..6de772071b 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -637,16 +637,15 @@ public: LLProcessorInfoDarwinImpl() { getCPUIDInfo(); -#ifdef __arm64__ - auto frequency = getSysctlInt64("hw.tbfrequency"); - struct clockinfo clockrate; - auto clockrate_len = sizeof(clockrate); - if (!sysctlbyname("kern.clockrate", &clockrate, &clockrate_len, - NULL, 0)) - frequency *= clockrate.hz; -#else uint64_t frequency = getSysctlInt64("hw.cpufrequency"); -#endif + if (!frequency) { + auto tbfrequency = getSysctlInt64("hw.tbfrequency"); + struct clockinfo clockrate; + auto clockrate_len = sizeof(clockrate); + if (!sysctlbyname("kern.clockrate", &clockrate, + &clockrate_len, NULL, 0)) + frequency = tbfrequency * clockrate.hz; + } setInfo(eFrequency, (F64)frequency / (F64)1000000); } |