Boost logo

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

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
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.


[1] Search "rdtsc"

Boost list run by bdawes at, gregod at, cpdaniel at, john at