Last active
August 29, 2015 14:10
-
-
Save spetroll/2be50240db6fb4084275 to your computer and use it in GitHub Desktop.
Timer
This file contains 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
from time import time | |
from functools import wraps | |
curr_ms = lambda: int(round(time() * 1000)) | |
def timed(f): | |
@wraps(f) | |
def wrapper(*args, **kwds): | |
start = curr_ms() | |
result = f(*args, **kwds) | |
elapsed = curr_ms() - start | |
print("{} took {}ms to finish".format(f.__name__, elapsed)) | |
return result | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment