Describe the bug
when calling sti.processes, I see CPU values switching from 0 to an high value alternately at each call.
Actual behavior
For instance, looking at my powerpoint.exe which has, according to taskmanager, cpu ~ 0%,, here are the results of a series of processes calls
powerpnt.exe {
"cpu": 0.004018299432017538
"cpu": 0
"cpu": 0.15141261641974887
"cpu": 0
"cpu": 36.95049504950495
"cpu": 0
"cpu": 37.270550678371904
}
and CPU usage when > 0 is increasing.
Expected behavior
I would expect a consistent series of values and closed to the taskmanager information.
Environment (please complete the following information):
for powerpoint .exe my procstat utime/stime are always the same at each call
call #1
cpuu = (procStat.utime (=n)- _cpu_old.list[procStat.pid].utime (=n)) === 0
so we store utime: cpuu > 0 ? procStat.utime : 0, === 0
call #2
cpuu = (procStat.utime (=n)- _cpu_old.list[procStat.pid].utime (=0)) === n
so we store utime: cpuu > 0 ? procStat.utime : 0, === procStat.utime (=n)
call #3
cpuu = (procStat.utime (=n)- _cpu_old.list[procStat.pid].utime (=n)) === 0
so we store utime: cpuu > 0 ? procStat.utime : 0, === 0
etc....
to be fair, I do not understand why we are not always saving the utime / stime without any condition related to the cpu.
I modified the code this way
Describe the bug when calling sti.processes, I see CPU values switching from 0 to an high value alternately at each call.
Actual behavior For instance, looking at my powerpoint.exe which has, according to taskmanager, cpu ~ 0%,, here are the results of a series of processes calls powerpnt.exe { "cpu": 0.004018299432017538 "cpu": 0 "cpu": 0.15141261641974887 "cpu": 0 "cpu": 36.95049504950495 "cpu": 0 "cpu": 37.270550678371904 } and CPU usage when > 0 is increasing.
Expected behavior I would expect a consistent series of values and closed to the taskmanager information.
Environment (please complete the following information):
Additional context According to the code
for powerpoint .exe my procstat utime/stime are always the same at each call call #1 cpuu = (procStat.utime (=n)- _cpu_old.list[procStat.pid].utime (=n)) === 0 so we store utime: cpuu > 0 ? procStat.utime : 0, === 0
call #2 cpuu = (procStat.utime (=n)- _cpu_old.list[procStat.pid].utime (=0)) === n so we store utime: cpuu > 0 ? procStat.utime : 0, === procStat.utime (=n)
call #3 cpuu = (procStat.utime (=n)- _cpu_old.list[procStat.pid].utime (=n)) === 0 so we store utime: cpuu > 0 ? procStat.utime : 0, === 0
etc....
to be fair, I do not understand why we are not always saving the utime / stime without any condition related to the cpu. I modified the code this way
and it works