Fix CPU percentage. Patch 3522180 for bug 3516978, by Richard.

This commit is contained in:
Hisham Muhammad 2012-05-28 00:47:05 +00:00
parent 05a78c8111
commit 90d567531a

View File

@ -677,7 +677,7 @@ static bool ProcessList_processEntries(ProcessList* this, const char* dirname, P
unsigned long long int lasttimes = (process->utime + process->stime);
if (! ProcessList_readStatFile(process, dirname, name, command))
goto errorReadingProcess;
int percent_cpu = (process->utime + process->stime - lasttimes) / period * 100.0;
float percent_cpu = (process->utime + process->stime - lasttimes) / period * 100.0;
process->percent_cpu = MAX(MIN(percent_cpu, cpus*100.0), 0.0);
if (isnan(process->percent_cpu)) process->percent_cpu = 0.0;
process->percent_mem = (process->m_resident * PAGE_SIZE_KB) / (double)(this->totalMem) * 100.0;