Skip to content

Instantly share code, notes, and snippets.

@rafaelhenrique
Last active July 14, 2018 15:03
Show Gist options
  • Select an option

  • Save rafaelhenrique/d69773a07bc79afbe2152de62b5d99e3 to your computer and use it in GitHub Desktop.

Select an option

Save rafaelhenrique/d69773a07bc79afbe2152de62b5d99e3 to your computer and use it in GitHub Desktop.
Measure things with timeit
from timeit import timeit
for_summation = """
summation = 0
for element in range(1, 1000):
summation += element
"""
summation = """
sum(range(1, 1000))
"""
time_for_summation = timeit(for_summation, number=3)
time_summation = timeit(summation, number=3)
print(time_for_summation)
print(time_summation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment