SHARE
TWEET

Untitled

a guest Feb 19th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import time
  2. from functools import wraps
  3.  
  4. def timeit(func):
  5.     @wraps(func)
  6.     def measure_time(*args, **kwargs):
  7.         start_time = time.time()
  8.         result = func(*args, **kwargs)
  9.         end_time = time.time()
  10.         print("@timefn: {} took {} seconds.".format(func.__name__, end_time - start_time))
  11.         return result
  12.     return measure_time
  13.  
  14. @timeit
  15. def func(a, b):
  16.     c = a + b
  17.     return c
  18.  
  19. print(func)
  20.  
  21. if __name__ == "__main__":
  22.     func(10, 20)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top