Advertisement
DariaFil

Decorator 3

Apr 24th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. import time
  2.  
  3.  
  4. def profiler():
  5.  
  6. def decorator(func):
  7. def wrapper(*args, **kwargs):
  8. func.last_time_taken = time.clock()
  9. func.calls += 1
  10. return func(*args, **kwargs)
  11. setattr(func, 'last_time_taken', 0)
  12. setattr(func, 'calls', 0)
  13. return wrapper
  14. return decorator
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement