mirror of https://github.com/xzeldon/htop.git
Fix CPU percentage. Patch 3522180 for bug 3516978, by Richard.
This commit is contained in:
parent
05a78c8111
commit
90d567531a
|
@ -677,7 +677,7 @@ static bool ProcessList_processEntries(ProcessList* this, const char* dirname, P
|
||||||
unsigned long long int lasttimes = (process->utime + process->stime);
|
unsigned long long int lasttimes = (process->utime + process->stime);
|
||||||
if (! ProcessList_readStatFile(process, dirname, name, command))
|
if (! ProcessList_readStatFile(process, dirname, name, command))
|
||||||
goto errorReadingProcess;
|
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);
|
process->percent_cpu = MAX(MIN(percent_cpu, cpus*100.0), 0.0);
|
||||||
if (isnan(process->percent_cpu)) process->percent_cpu = 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;
|
process->percent_mem = (process->m_resident * PAGE_SIZE_KB) / (double)(this->totalMem) * 100.0;
|
||||||
|
|
Loading…
Reference in New Issue