Created
December 6, 2012 00:31
-
-
Save craigbeck/4220873 to your computer and use it in GitHub Desktop.
python decorator to time method execution
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
# 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