mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-28 15:53:51 +01:00
CPUUsage(Windows): add new method using Windows Performance Library
This commit is contained in:
@@ -27,6 +27,11 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
if (*percent == *percent)
|
||||
{
|
||||
sumValue += *percent;
|
||||
|
||||
#if FF_ENABLE_CPUUSAGE_PERFLIB
|
||||
// Windows may return values greater than 100%, cap them to 100%
|
||||
if (*percent > 100) *percent = 100;
|
||||
#endif
|
||||
if (*percent > maxValue)
|
||||
{
|
||||
maxValue = *percent;
|
||||
@@ -42,6 +47,10 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
++index;
|
||||
}
|
||||
double avgValue = sumValue / (double) valueCount;
|
||||
#if FF_ENABLE_CPUUSAGE_PERFLIB
|
||||
// See above comment
|
||||
if (avgValue > 100) avgValue = 100;
|
||||
#endif
|
||||
|
||||
FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user