CPUUsage: don't count NaN values

This commit is contained in:
李通洲
2023-11-01 15:55:13 +08:00
parent 256c9be19b
commit 4cabc5684b
+3 -2
View File
@@ -22,7 +22,7 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
double maxValue = -999, minValue = 999, sumValue = 0;
uint32_t maxIndex = 999, minIndex = 999;
uint32_t index = 0;
uint32_t index = 0, valueCount = 0;
FF_LIST_FOR_EACH(double, percent, percentages)
{
if (*percent == *percent)
@@ -38,10 +38,11 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
minValue = *percent;
minIndex = index;
}
++valueCount;
}
++index;
}
double avgValue = sumValue / (double) percentages.length;
double avgValue = sumValue / (double) valueCount;
if(options->moduleArgs.outputFormat.length == 0)
{