Fix a problem where CPU time was computed wrong.

This definitely affected FreeBSD, which breaks POSIX.1 by not
setting CLOCKS_PER_SEC to 1000000 (see clock(3)).  At this point
I can't tell if any other platforms were affected by this.
This commit is contained in:
Bruce A. Mah 2014-04-25 12:50:15 -07:00
parent 5069cc1329
commit bf219a4d51

View File

@ -189,7 +189,7 @@ cpu_util(double pcpu[3])
systemdiff = ((rtemp.ru_stime.tv_sec * 1000000.0 + rtemp.ru_stime.tv_usec) -
(rlast.ru_stime.tv_sec * 1000000.0 + rlast.ru_stime.tv_usec));
pcpu[0] = ((ctemp - clast) / timediff) * 100;
pcpu[0] = (((ctemp - clast) * 1000000.0 / CLOCKS_PER_SEC) / timediff) * 100;
pcpu[1] = (userdiff / timediff) * 100;
pcpu[2] = (systemdiff / timediff) * 100;
}