am 73d2059f: Merge "Explain why clock(3) isn\'t broken."

* commit '73d2059f9b3f53446e25d800d64a86efb3bf3f9f':
  Explain why clock(3) isn't broken.
This commit is contained in:
Elliott Hughes 2014-09-13 00:16:26 +00:00 committed by Android Git Automerger
commit 934028eba3

View File

@ -34,5 +34,8 @@
clock_t clock() { clock_t clock() {
tms t; tms t;
times(&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)); return (t.tms_utime + t.tms_stime) * (CLOCKS_PER_SEC / sysconf(_SC_CLK_TCK));
} }