Skip to content

Instantly share code, notes, and snippets.

@danielthiel
Created May 4, 2015 11:16
Show Gist options
  • Save danielthiel/220a8133023fff09c257 to your computer and use it in GitHub Desktop.
Save danielthiel/220a8133023fff09c257 to your computer and use it in GitHub Desktop.
time the application execution of fn to args
"""
by: Peter Norvig
http://norvig.com/python-iaq.html
"""
def timer(fn, *args):
"Time the application of fn to args. Return (result, seconds)."
import time
start = time.clock()
return fn(*args), time.clock() - start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment