Skip to content

Commit

Permalink
disabled incomplete macOS SystemSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
vackva committed Apr 24, 2024
1 parent 00d106f commit 39783b3
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions source/utils/SystemSpecs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,27 @@
static unsigned long long _previousTotalTicks = 0;
static unsigned long long _previousIdleTicks = 0;

SystemSpecs::getCPULoad() {
host_cpu_load_info_data_t cpuinfo;
mach_msg_type_number_t count = HOST_CPU_LOAD_INFO_COUNT;
if (host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO, (host_info_t)&cpuinfo, &count) == KERN_SUCCESS)
{
unsigned long long totalTicks = 0;
for(int i=0; i<CPU_STATE_MAX; i++) totalTicks += cpuinfo.cpu_ticks[i];
return calculateCPULoad(cpuinfo.cpu_ticks[CPU_STATE_IDLE], totalTicks);
}
else return -1.0f;
double SystemSpecs::getCPULoad() {
// host_cpu_load_info_data_t cpuinfo;
// mach_msg_type_number_t count = HOST_CPU_LOAD_INFO_COUNT;
// if (host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO, (host_info_t)&cpuinfo, &count) == KERN_SUCCESS)
// {
// unsigned long long totalTicks = 0;
// for(int i=0; i<CPU_STATE_MAX; i++) totalTicks += cpuinfo.cpu_ticks[i];
// return calculateCPULoad(cpuinfo.cpu_ticks[CPU_STATE_IDLE], totalTicks);
// }
// else return -1.0f;
return 0.0;
}

SystemSpecs::calculateCPULoad() {
unsigned long long totalTicksSinceLastTime = totalTicks-_previousTotalTicks;
unsigned long long idleTicksSinceLastTime = idleTicks-_previousIdleTicks;
float ret = 1.0f-((totalTicksSinceLastTime > 0) ? ((float)idleTicksSinceLastTime)/totalTicksSinceLastTime : 0);
_previousTotalTicks = totalTicks;
_previousIdleTicks = idleTicks;
return ret;
double SystemSpecs::calculateCPULoad() {
// unsigned long long totalTicksSinceLastTime = totalTicks-_previousTotalTicks;
// unsigned long long idleTicksSinceLastTime = idleTicks-_previousIdleTicks;
// float ret = 1.0f-((totalTicksSinceLastTime > 0) ? ((float)idleTicksSinceLastTime)/totalTicksSinceLastTime : 0);
// _previousTotalTicks = totalTicks;
// _previousIdleTicks = idleTicks;
// return ret;
return 0.0;
}
#endif

Expand Down

0 comments on commit 39783b3

Please sign in to comment.