Browse Source

MacOS SystemStats: Implement M1 CPU reporting

v7.0.9
Oli Oliver James 3 years ago
parent
commit
6f8c2a26a0
1 changed files with 16 additions and 8 deletions
  1. +16
    -8
      modules/juce_core/native/juce_mac_SystemStats.mm

+ 16
- 8
modules/juce_core/native/juce_mac_SystemStats.mm View File

@@ -209,7 +209,7 @@ String SystemStats::getCpuVendor()
return String (reinterpret_cast<const char*> (vendor), 12);
#else
return {};
return "Apple";
#endif
}
@@ -226,17 +226,25 @@ String SystemStats::getCpuModel()
int SystemStats::getCpuSpeedInMegahertz()
{
#ifdef JUCE_INTEL
uint64 speedHz = 0;
size_t speedSize = sizeof (speedHz);
size_t optSize = sizeof (speedHz);
int mib[] = { CTL_HW, HW_CPU_FREQ };
sysctl (mib, 2, &speedHz, &speedSize, nullptr, 0);
#if JUCE_BIG_ENDIAN
if (speedSize == 4)
speedHz >>= 32;
#endif
sysctl (mib, 2, &speedHz, &optSize, nullptr, 0);
return (int) (speedHz / 1000000);
#else
size_t hz = 0;
size_t optSize = sizeof (hz);
sysctlbyname ("hw.tbfrequency", &hz, &optSize, nullptr, 0);
struct clockinfo ci{};
optSize = sizeof (ci);
int mib[] = { CTL_KERN, KERN_CLOCKRATE };
sysctl (mib, 2, &ci, &optSize, nullptr, 0);
return (int) (double (hz * uint64_t (ci.hz)) / 1000000.0);
#endif
}
//==============================================================================


Loading…
Cancel
Save