Skip to content

Instantly share code, notes, and snippets.

@brydavis
Last active August 10, 2019 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brydavis/0af699668d59d21e78fcf0b5d2f934a6 to your computer and use it in GitHub Desktop.
Save brydavis/0af699668d59d21e78fcf0b5d2f934a6 to your computer and use it in GitHub Desktop.
UWPCE - Lesson 06
import time
import math
# from timeit import timeit
# print(timeit('[x for x in range(100)]', number=1000))
# print(timeit('[x for x in range(100)]', number=1000))
# print(timeit(lambda: [x for x in range(100)], number=1000))
def do_math():
for n in range(1000, 1000000):
math.sqrt(n)
def take_break():
# baseline overhead
time.sleep(2)
def do_work():
for n in range(1000,10000):
# [x for x in range(n)]
list(range(n))
if __name__ == "__main__":
do_math()
take_break()
do_work()
take_break()
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment