Created
January 17, 2022 07:59
-
-
Save esenthil2018/b5d55d9d280892278a6b82238cae6a93 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