Skip to content

Instantly share code, notes, and snippets.

@metula
Created December 18, 2013 21:51
Show Gist options
  • Save metula/8030452 to your computer and use it in GitHub Desktop.
Save metula/8030452 to your computer and use it in GitHub Desktop.
import time
def elapsed(expression, number=1):
''' computes elapsed time for executing code
number of times (default is 1 time). expression should
be a string representing a Python expression. '''
t1 = time.clock()
for i in range(number):
eval(expression)
t2 = time.clock()
return t2 - t1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment