getrusage vs clock

Niels Möller nisse at
Fri Jan 22 07:54:52 UTC 2016

tg at (Torbjörn Granlund) writes:

> I believe we already use clock_gettime(2) directly on GNU/Linux, which
> is the underlying syscall that clock(3) uses in newer GNU libc versions.

Last time I looked, one had to run speed with -o cycles-broken to force
using clock_gettime.

Maybe it would make sense to use cycle counter and clock_gettime
together? But I have no idea how the "supplemented by" logic works.

The problem with the cycle counter on linux is that it isn't saved and
restored on context switch. clock_gettime is the supported interface for
getting high precision per-process cpu time. 

And it's news to me that the old clock function uses the same timers in
recent glibc. But it sounds nice. What's the value of CLOCKS_PER_SEC?
Does it match the actual resolution?


Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.

More information about the gmp-devel mailing list