Do the math correctly to avoid loss of precision for rtime.
I've noticed this with system-monitor where all processes got a perfectly round CPU time to the second.
This commit is contained in:
@@ -80,7 +80,6 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
|
||||
|
||||
glibtop_suid_leave (server);
|
||||
|
||||
buf->rtime = pinfo [0].ki_runtime * 1e-6;
|
||||
|
||||
len = sizeof (ci);
|
||||
if (sysctlbyname ("kern.clockrate", &ci, &len, NULL, 0)) {
|
||||
@@ -90,10 +89,9 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
|
||||
}
|
||||
|
||||
buf->frequency = (ci.stathz ? ci.stathz : ci.hz);
|
||||
buf->rtime = pinfo [0].ki_runtime * buf->frequency / 1000000;
|
||||
buf->flags = _glibtop_sysdeps_proc_time;
|
||||
|
||||
buf->rtime *= buf->frequency;
|
||||
|
||||
if ((pinfo [0].ki_flag & PS_INMEM)) {
|
||||
buf->utime = (pinfo [0].ki_runtime * 1e-6) * buf->frequency;
|
||||
buf->stime = tv2sec (pinfo [0].ki_rusage.ru_stime) * buf->frequency;
|
||||
|
Reference in New Issue
Block a user