The clock() documentation https://www.gnu.org/software/libc/manual/html_node/CPU-Time.html should say something about the implementation and the accuracy (the code could be better documented too), possibly with official references. This is in relation to bug 12515, about the implementation change. In this bug, it is said: "clock() should provide better precision". However the user doesn't seek improved precision, but improved accuracy: if one gets more digits but the value itself is less accurate (i.e. the error against the ideal value is larger), this is bad. All this depends on the kernel implementation, but I don't know anything about it. In addition to improved precision, does one also get better accuracy? I suppose yes, but the answer is not obvious. Such a documentation is important, as the user may wonder: Should I use clock() or something else? Note that the clock(3) man page http://man7.org/linux/man-pages/man3/clock.3.html says something about the implementation: In glibc 2.17 and earlier, clock() was implemented on top of times(2). For improved precision, since glibc 2.18, it is implemented on top of clock_gettime(2) (using the CLOCK_PROCESS_CPUTIME_ID clock). but with the poorly chosen reason "improved precision" instead of "improved accuracy".
Let's note that with CLOCKS_PER_SEC = 1000000, clock() has a fixed precision of 1 ms. What have changed are: * the precision of the underlying function; * as a consequence, the accuracy of the clock() function. But it is still unclear what it actually is.
(In reply to Vincent Lefèvre from comment #1) > Let's note that with CLOCKS_PER_SEC = 1000000, clock() has a fixed precision > of 1 ms. Sorry, I meant 1 µs.