/* Only works in x86_64. - https://en.wikipedia.org/wiki/Time_Stamp_Counter - https://stackoverflow.com/questions/9887839/clock-cycle-count-wth-gcc/9887979 */ #include #include #include #if defined(__i386__) || defined(__x86_64__) #include #endif int main(void) { uintmax_t val; #if defined(__i386__) || defined(__x86_64__) val = __rdtsc(); #else val = 0; #endif printf("%ju\n", val); return EXIT_SUCCESS; }