|
Boost : |
From: dherring_at_[hidden]
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
functionality.
Apparently MS compilers support an __rdtsc() intrinsic, but I couldn't
find one for gcc.
The code at
http://www-unix.mcs.anl.gov/~kazutomo/rdtsc.html
seems to do a good job for gcc; it avoids a couple bugs in code found at
other sites.
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[1]; I
just want a portable way to access the raw counter itself.
Thanks,
Daniel
[1] 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