Skip to content

Instantly share code, notes, and snippets.

@craigbeck
Created December 6, 2012 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigbeck/4220873 to your computer and use it in GitHub Desktop.
Save craigbeck/4220873 to your computer and use it in GitHub Desktop.
python decorator to time method execution
# timing func
import time
import logging
def log_timing(func):
def inner(*args, **kwargs):
t1 = time.time()
res = func(*args, **kwargs)
t2 = time.time()
logging.getLogger().debug('%s took %0.3f ms' % (func.func_name, (t2-t1)*1000.0))
return res
return inner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment