Created
November 10, 2012 14:43
-
-
Save maniartech/4051292 to your computer and use it in GitHub Desktop.
A python decorator that prints the function execution duration useful for bench-marking.
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
def benchmark(func): | |
""" | |
A decorator that prints the function execution duration useful for bench-marking. | |
""" | |
import time | |
def wrapper(*args, **kwargs): | |
t = time.clock() | |
res = func(*args, **kwargs) | |
print func.__name__, time.clock()-t | |
return res | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment