Skip to content

Instantly share code, notes, and snippets.

@tateg
Last active December 16, 2021 01:16
Show Gist options
  • Save tateg/792f63f4647e92895778b5e1862ec02c to your computer and use it in GitHub Desktop.
Save tateg/792f63f4647e92895778b5e1862ec02c to your computer and use it in GitHub Desktop.
A bad way to time threaded infinite loops
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