Skip to content

Commit 4cabc56

Browse files
committed
CPUUsage: don't count NaN values
1 parent 256c9be commit 4cabc56

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/modules/cpuusage/cpuusage.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
2222
double maxValue = -999, minValue = 999, sumValue = 0;
2323
uint32_t maxIndex = 999, minIndex = 999;
2424

25-
uint32_t index = 0;
25+
uint32_t index = 0, valueCount = 0;
2626
FF_LIST_FOR_EACH(double, percent, percentages)
2727
{
2828
if (*percent == *percent)
@@ -38,10 +38,11 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
3838
minValue = *percent;
3939
minIndex = index;
4040
}
41+
++valueCount;
4142
}
4243
++index;
4344
}
44-
double avgValue = sumValue / (double) percentages.length;
45+
double avgValue = sumValue / (double) valueCount;
4546

4647
if(options->moduleArgs.outputFormat.length == 0)
4748
{

0 commit comments

Comments
 (0)