Created
October 1, 2016 04:52
-
-
Save sighingnow/3f07e028ae7e0b51ef5fa57cb1f8f1ab to your computer and use it in GitHub Desktop.
Demo of Read Time-Stamp Counter (rdstc instruction).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* author: Tao He, sighingnow@gmail.com | |
*/ | |
uint64_t rdtsc() { | |
uint32_t lo, hi; | |
__asm__ __volatile__("rdtsc" : "=a"(lo), "=d"(hi)); | |
return (uint64_t)hi << 32 | lo; | |
} | |
int main(int, char **) { | |
printf("%llu\n", rdtsc()); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment