Skip to content

Instantly share code, notes, and snippets.

@nuta
Created January 20, 2015 11:30
Show Gist options
  • Save nuta/12d1ece81b32030b264a to your computer and use it in GitHub Desktop.
Save nuta/12d1ece81b32030b264a to your computer and use it in GitHub Desktop.
#include <stdio.h>
static inline void _main (void){
}
typedef unsigned long long u64;
static inline u64 cycle (void){
u64 stamp;
__asm__ __volatile__("rdtscp; shl $32,%%rdx; or %%rdx,%%rax" : "=a"(stamp));
return stamp;
}
u64 try (void){
u64 st,end;
st = cycle();
_main();
end = cycle();
printf("%llu\n", end-st);
return 0;
}
int main (void){
for(int i=0; i <= 1000; i++)
try();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment