Update IO rate display to use NAN on error

This commit is contained in:
Benny Baumann
2020-09-07 11:53:58 +02:00
committed by cgzones
parent 47e2cefe02
commit 29ec115143
3 changed files with 13 additions and 6 deletions

View File

@ -17,6 +17,7 @@ in the source distribution for its full text.
#include <string.h>
#include <sys/syscall.h>
#include <time.h>
#include <math.h>
/* semi-global */
long long btime;
@ -237,9 +238,15 @@ void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field)
case IO_READ_RATE: Process_outputRate(str, buffer, n, lp->io_rate_read_bps, coloring); return;
case IO_WRITE_RATE: Process_outputRate(str, buffer, n, lp->io_rate_write_bps, coloring); return;
case IO_RATE: {
double totalRate = (lp->io_rate_read_bps != -1)
? (lp->io_rate_read_bps + lp->io_rate_write_bps)
: -1;
double totalRate = NAN;
if(!isnan(lp->io_rate_read_bps) && !isnan(lp->io_rate_write_bps))
totalRate = lp->io_rate_read_bps + lp->io_rate_write_bps;
else if(!isnan(lp->io_rate_read_bps))
totalRate = lp->io_rate_read_bps;
else if(!isnan(lp->io_rate_write_bps))
totalRate = lp->io_rate_write_bps;
else
totalRate = NAN;
Process_outputRate(str, buffer, n, totalRate, coloring); return;
}
#endif