Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. $ python
  2. Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
  3. [GCC 4.4.5] on linux2
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>> import time
  6. >>> from decorator import decorator
  7. >>>
  8. >>> @decorator
  9. ... def timer(func, *args, **kws):
  10. ...     t = time.time()
  11. ...     res = func(*args, **kws)
  12. ...     print 'Время выполнения функции %s: %f' % (func.__name__, time.time()-t)...     return res
  13. ...
  14. >>> @timer
  15. ... def tesstrigs1():
  16. ...     for i in range(1000000):
  17. ...         s = '%s%s%s' % ('Neko ', 'ko ', 'neko')
  18. ...
  19. >>> @timer
  20. ... def tesstrigs2():
  21. ...     for i in range(1000000):
  22. ...         s = 'Neko '+'ko '+'neko'
  23. ...
  24. >>> tesstrigs1()
  25. Время выполнения функции tesstrigs1: 0.417575
  26. >>> tesstrigs2()
  27. Время выполнения функции tesstrigs2: 0.070478
  28. >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement