Explain why clock(3) isn't broken.

Bug: 17441123
Bug: 17814435

(cherry picked from commit f83c208b82c78dad07f4065f63bdd354f5ef9951)

Change-Id: I2065afe73b79a8d86404edee16e983625d902cdc
This commit is contained in:
Elliott Hughes 2014-09-12 16:33:37 -07:00
parent aaad548535
commit ea9800e985

View File

@ -34,5 +34,8 @@
clock_t clock() {
tms t;
times(&t);
// Although times(2) and clock(3) both use the type clock_t, the units are
// different. For times(2) it's pure clock ticks, but for clock(3) the unit
// is CLOCKS_PER_SEC, so we need to scale appropriately.
return (t.tms_utime + t.tms_stime) * (CLOCKS_PER_SEC / sysconf(_SC_CLK_TCK));
}