Skip to content

Instantly share code, notes, and snippets.

@spetroll
Last active August 29, 2015 14:10
Show Gist options
  • Save spetroll/2be50240db6fb4084275 to your computer and use it in GitHub Desktop.
Save spetroll/2be50240db6fb4084275 to your computer and use it in GitHub Desktop.
Timer
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