import time
# Set your CPU frequency in Hz (e.g., 3.0 GHz CPU is 3_000_000_000 cycles per second)
CPU_FREQUENCY_HZ = 3_000_000_000 # 3 GHz
# Number of iterations for the loop
loop_count = 1000000
# Start time in seconds (high-resolution timestamp)
start_time = time.perf_counter()
# Execute the loop
for _ in range(loop_count):
pass # No-operation equivalent
# End time in seconds
end_time = time.perf_counter()
# Calculate the elapsed time in seconds
elapsed_time = end_time - start_time
# Convert elapsed time to CPU cycles
elapsed_cycles = int(elapsed_time * CPU_FREQUENCY_HZ)
# Display the result
print(f"Time taken: {elapsed_cycles} cycles")
aW1wb3J0IHRpbWUKCiMgU2V0IHlvdXIgQ1BVIGZyZXF1ZW5jeSBpbiBIeiAoZS5nLiwgMy4wIEdIeiBDUFUgaXMgM18wMDBfMDAwXzAwMCBjeWNsZXMgcGVyIHNlY29uZCkKQ1BVX0ZSRVFVRU5DWV9IWiA9IDNfMDAwXzAwMF8wMDAgICMgMyBHSHoKCiMgTnVtYmVyIG9mIGl0ZXJhdGlvbnMgZm9yIHRoZSBsb29wCmxvb3BfY291bnQgPSAxMDAwMDAwCgojIFN0YXJ0IHRpbWUgaW4gc2Vjb25kcyAoaGlnaC1yZXNvbHV0aW9uIHRpbWVzdGFtcCkKc3RhcnRfdGltZSA9IHRpbWUucGVyZl9jb3VudGVyKCkKCiMgRXhlY3V0ZSB0aGUgbG9vcApmb3IgXyBpbiByYW5nZShsb29wX2NvdW50KToKICAgIHBhc3MgICMgTm8tb3BlcmF0aW9uIGVxdWl2YWxlbnQKCiMgRW5kIHRpbWUgaW4gc2Vjb25kcwplbmRfdGltZSA9IHRpbWUucGVyZl9jb3VudGVyKCkKCiMgQ2FsY3VsYXRlIHRoZSBlbGFwc2VkIHRpbWUgaW4gc2Vjb25kcwplbGFwc2VkX3RpbWUgPSBlbmRfdGltZSAtIHN0YXJ0X3RpbWUKCiMgQ29udmVydCBlbGFwc2VkIHRpbWUgdG8gQ1BVIGN5Y2xlcwplbGFwc2VkX2N5Y2xlcyA9IGludChlbGFwc2VkX3RpbWUgKiBDUFVfRlJFUVVFTkNZX0haKQoKIyBEaXNwbGF5IHRoZSByZXN1bHQKcHJpbnQoZiJUaW1lIHRha2VuOiB7ZWxhcHNlZF9jeWNsZXN9IGN5Y2xlcyIpCg==