From: Johan Råde (rade_at_[hidden])
Date: 2008-06-09 15:31:42
> 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.
MSVS 8.0 and higher have the __rdtsc intrinsic.
Om earlier versions of MSVC you can use the following inline assembler:
inline uint64_t clockCycleCount()
cpuid // serialize processor
rdtsc // read time stamp counter
mov dword ptr [ccc + 0], eax
mov dword ptr [ccc + 4], edx
I agree that a platform independent version would be useful.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk