Skip to content

Instantly share code, notes, and snippets.

@ashchristopher
Created September 30, 2012 18:38
Show Gist options
  • Select an option

  • Save ashchristopher/3808106 to your computer and use it in GitHub Desktop.

Select an option

Save ashchristopher/3808106 to your computer and use it in GitHub Desktop.
Timing a function decorator
import time
def print_timing(func):
def wrapper(*arg):
t1 = time.time()
res = func(*arg)
t2 = time.time()
print '%s took %0.3f ms' % (func.func_name, (t2-t1)*1000.0)
return res
return wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment