Last active
July 16, 2017 07:28
-
-
Save SS1031/b8cabea4648e5d508987d0e330140696 to your computer and use it in GitHub Desktop.
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
def stopwatch(func): | |
@functools.wraps(func) | |
def wrapper(*args, **kwargs): | |
start = time.time() | |
result = func(*args, **kwargs) | |
end = time.time() | |
print("Function[{}]".format(func.__name__), ", {0:d} min {1:d} sec".format( | |
int(end - start) // 60, int((end - start) % 60))) | |
return result | |
return wrapper | |
@stopwatch | |
def test_watch(): | |
summation = 0 | |
for i in range(100000000): | |
summation += i | |
if __name__ == '__main__': | |
test_watch() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment