#include <stdio.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> // For Windows (MSVC compiler)
#else
#include <x86intrin.h> // For GCC/Clang on x86 platforms
#endif
int main() {
uint64_t start_time, end_time, time_diff;
int i, loop_count = 1000000;
// Get start time (in CPU cycles)
start_time = __rdtsc();
// Loop to measure
for (i = 0; i < loop_count; i++) {
__asm__ __volatile__("nop"); // No-operation to simulate work
}
// Get end time (in CPU cycles)
end_time = __rdtsc();
// Calculate time difference
time_diff = end_time - start_time;
// Print the time taken in CPU cycles
printf("Time taken: %llu cycles\n", time_diff
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRpbnQuaD4KI2lmZGVmIF9NU0NfVkVSCiNpbmNsdWRlIDxpbnRyaW4uaD4gIC8vIEZvciBXaW5kb3dzIChNU1ZDIGNvbXBpbGVyKQojZWxzZQojaW5jbHVkZSA8eDg2aW50cmluLmg+ICAvLyBGb3IgR0NDL0NsYW5nIG9uIHg4NiBwbGF0Zm9ybXMKI2VuZGlmCgppbnQgbWFpbigpIHsKICAgIHVpbnQ2NF90IHN0YXJ0X3RpbWUsIGVuZF90aW1lLCB0aW1lX2RpZmY7CiAgICBpbnQgaSwgbG9vcF9jb3VudCA9IDEwMDAwMDA7CgogICAgLy8gR2V0IHN0YXJ0IHRpbWUgKGluIENQVSBjeWNsZXMpCiAgICBzdGFydF90aW1lID0gX19yZHRzYygpOwoKICAgIC8vIExvb3AgdG8gbWVhc3VyZQogICAgZm9yIChpID0gMDsgaSA8IGxvb3BfY291bnQ7IGkrKykgewogICAgICAgIF9fYXNtX18gX192b2xhdGlsZV9fKCJub3AiKTsgIC8vIE5vLW9wZXJhdGlvbiB0byBzaW11bGF0ZSB3b3JrCiAgICB9CgogICAgLy8gR2V0IGVuZCB0aW1lIChpbiBDUFUgY3ljbGVzKQogICAgZW5kX3RpbWUgPSBfX3JkdHNjKCk7CgogICAgLy8gQ2FsY3VsYXRlIHRpbWUgZGlmZmVyZW5jZQogICAgdGltZV9kaWZmID0gZW5kX3RpbWUgLSBzdGFydF90aW1lOwoKICAgIC8vIFByaW50IHRoZSB0aW1lIHRha2VuIGluIENQVSBjeWNsZXMKICAgIHByaW50ZigiVGltZSB0YWtlbjogJWxsdSBjeWNsZXNcbiIsIHRpbWVfZGlmZik7CgogICAgcmV0dXJuIDA7Cn0=