__rdtsc -- Read Time Stamp Counter

Format

#include <builtin.h>
unsigned long long __rdtsc(void)

Language Level: None
__rdtsc returns the current value of the processor's time-stamp counter. The processor increments the time-stamp counter every clock cycle and resets it to 0 whenever the processor is reset. This builtin function will not work on a 386 or 486 processor.

Return Value
Returns the current value of the processor's time-stamp counter.

Example
This example prints out the current value of the processor's time-stamp counter.

#include <stdio.h>
#include <builtin.h>
int main(void)
{
   printf("The time stamp counter value is %.8llx\n", __rdtsc());
   /*************************************************************
      The output should be (the actual counter value will vary):
      The time stamp counter value is 53af6dd46631
   *************************************************************/
   return 0;
}