Created
March 5, 2017 17:45
-
-
Save jarun/d91c9ef5b9ef1720042e47f91a097dae to your computer and use it in GitHub Desktop.
Quick template for python 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
#!/usr/bin/env python3 | |
import timeit | |
''' | |
plus_stmt = """ | |
row1 = 'hello world' | |
row2 = 'hello worlds' | |
out = '- [' + row2 + '](' + row1 + ')' | |
""" | |
x = timeit.Timer(plus_stmt) | |
print(x.timeit(100)) | |
''' | |
percent_stmt = """ | |
row1 = 'hello world' | |
row2 = 'hello worlds' | |
out = '- [%s](%s)' % (row2, row1) | |
""" | |
x = timeit.Timer(percent_stmt) | |
print(x.timeit(100)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment