-
-
Save esenthil2018/d7e706f4a12ff31733f9a4d3d9121fad 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 time(fn): | |
| from functools import wraps | |
| from time import perf_counter | |
| @wraps(fn) | |
| def wrapper(*args, **kwargs): | |
| start = perf_counter() | |
| res = fn(*args, **kwargs) | |
| end = perf_counter() | |
| print('{0} ran for {1:.6f}s'.format(fn.__name__, end-start)) | |
| return res | |
| return wrapper | |
| @time | |
| def product(a,b,c): | |
| print('The product of a*b*c:', a*b*c) | |
| product(3,5,6) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment