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 str_concat_test_1(a, b):
- ... for i in xrange(1000000):
- ... s = '%s%s' % (a, b)
- ...
- >>> @timer
- ... def str_concat_test_2(a, b):
- ... for i in xrange(1000000):
- ... s = a + b
- ...
- >>> @timer
- ... def str_concat_test_3(a, b):
- ... for i in xrange(1000000):
- ... s = ''.join((a, b))
- ...
- >>> str_concat_test_1('Nya ', 'kawaii')
- Время выполнения функции str_concat_test_1: 0.382882
- >>> str_concat_test_2('Nya ', 'kawaii')
- Время выполнения функции str_concat_test_2: 0.132083
- >>> str_concat_test_3('Nya ', 'kawaii')
- Время выполнения функции str_concat_test_3: 0.306145
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement