Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ python
- Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
- [GCC 4.4.5] on linux2
- Type "help", "copyright", "credits" or "license" for more information.
- >>> import time
- >>> from decorator import decorator
- >>>
- >>> @decorator
- ... def timer(func, *args, **kws):
- ... t = time.time()
- ... res = func(*args, **kws)
- ... print 'Время выполнения функции %s: %f' % (func.__name__, time.time()-t)... return res
- ...
- >>> @timer
- ... def tesstrigs1():
- ... for i in range(1000000):
- ... s = '%s%s%s' % ('Neko ', 'ko ', 'neko')
- ...
- >>> @timer
- ... def tesstrigs2():
- ... for i in range(1000000):
- ... s = 'Neko '+'ko '+'neko'
- ...
- >>> tesstrigs1()
- Время выполнения функции tesstrigs1: 0.417575
- >>> tesstrigs2()
- Время выполнения функции tesstrigs2: 0.070478
- >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement