Created
May 4, 2015 11:16
-
-
Save danielthiel/220a8133023fff09c257 to your computer and use it in GitHub Desktop.
time the application execution of fn to args
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
""" | |
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