Skip to content

Instantly share code, notes, and snippets.

@rigtorp
Created December 4, 2018 22:29
Show Gist options
  • Save rigtorp/82dfc060b86a3aef093759669bad02c0 to your computer and use it in GitHub Desktop.
Save rigtorp/82dfc060b86a3aef093759669bad02c0 to your computer and use it in GitHub Desktop.
Read rdtsc
static inline uint64_t rdtsc() {
uint64_t hi, lo;
asm volatile ("mfence; rdtsc\n" : "=a" (lo), "=d" (hi));
return (hi << 32) | lo;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment