Date: 2008-06-09 13:11:03
The CPU timestamp counter is a high-resolution clock source useful for
profiling code or controlling tight timing loops. AMD/Intel CPUs support
this via the RDTSC opcode, and other CPUs often provide similar
Apparently MS compilers support an __rdtsc() intrinsic, but I couldn't
find one for gcc.
The code at
seems to do a good job for gcc; it avoids a couple bugs in code found at
Any possibility of a raw boost::rdtsc() or boost::readTSC()? Something
that doesn't compile on unsupported architectures would be good.
Other code can worry about whether this is an accurate time source; I
just want a portable way to access the raw counter itself.
 Search "rdtsc site:boost.org"
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk