Skip to content

Instantly share code, notes, and snippets.

@emilisto
Created December 27, 2014 18:11
Show Gist options
  • Save emilisto/ebe269de2c92c550e7f7 to your computer and use it in GitHub Desktop.
Save emilisto/ebe269de2c92c550e7f7 to your computer and use it in GitHub Desktop.
Time it and print friendly output
from timeit import timeit
def timeit_and_print(stmt, setup='pass', number=100000):
t = timeit(stmt, setup=setup)
print 'Executed "%s" %d times in %.4f seconds, %.4f ms per call (%d calls per second)' % (
stmt, number, t, 1000 * t / number, int(number / t))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment