Last active
December 16, 2021 01:16
-
-
Save tateg/792f63f4647e92895778b5e1862ec02c to your computer and use it in GitHub Desktop.
A bad way to time threaded infinite loops
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run(self): | |
while True: | |
before_ts = time_ns() | |
for num in range(0, 1000): | |
print(num) | |
after_ts = time_ns() | |
print('loop time: ' + str(after_ts - before_ts)) | |
sleep(1) | |
print('loop complete') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment