Skip to content

Instantly share code, notes, and snippets.

@esenthil2018
Created January 16, 2022 04:54
Show Gist options
  • Select an option

  • Save esenthil2018/d7e706f4a12ff31733f9a4d3d9121fad to your computer and use it in GitHub Desktop.

Select an option

Save esenthil2018/d7e706f4a12ff31733f9a4d3d9121fad to your computer and use it in GitHub Desktop.
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