Created
September 30, 2012 18:38
-
-
Save ashchristopher/3808106 to your computer and use it in GitHub Desktop.
Timing a function decorator
This file contains hidden or 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
| 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