Last active
July 14, 2018 15:03
-
-
Save rafaelhenrique/d69773a07bc79afbe2152de62b5d99e3 to your computer and use it in GitHub Desktop.
Measure things with timeit
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
| 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