Skip to content

Instantly share code, notes, and snippets.

@jarun
Created March 5, 2017 17:45
Show Gist options
  • Save jarun/d91c9ef5b9ef1720042e47f91a097dae to your computer and use it in GitHub Desktop.
Save jarun/d91c9ef5b9ef1720042e47f91a097dae to your computer and use it in GitHub Desktop.
Quick template for python timeit
#!/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