Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <redacted>$ python
- Python 2.7.17 (default, Apr 15 2020, 17:20:14)
- [GCC 7.5.0] on linux2
- Type "help", "copyright", "credits" or "license" for more information.
- >>> import random
- >>> import string
- >>> import cProfile
- >>>
- >>> def chrs(bits, len_string):
- ... return ''.join(chr((bits >> (8*x)) & 0xff) for x in range(len_string))
- ...
- >>>
- >>> def bits_strings(num_strings, len_string):
- ... return list(chrs(random.getrandbits(len_string*8), len_string) for x in range(num_strings))
- ...
- >>> cProfile.run('bits_strings(1000, 1000)')
- 2005004 function calls in 0.802 seconds
- Ordered by: standard name
- ncalls tottime percall cumtime percall filename:lineno(function)
- 1 0.000 0.000 0.803 0.803 <stdin>:1(bits_strings)
- 1000 0.001 0.000 0.799 0.001 <stdin>:1(chrs)
- 1001000 0.608 0.000 0.699 0.000 <stdin>:2(<genexpr>)
- 1 0.000 0.000 0.803 0.803 <string>:1(<module>)
- 1000000 0.091 0.000 0.091 0.000 {chr}
- 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
- 1000 0.003 0.000 0.003 0.000 {method 'getrandbits' of '_random.Random' objects}
- 1000 0.095 0.000 0.794 0.001 {method 'join' of 'str' objects}
- 1001 0.004 0.000 0.004 0.000 {range}
- >>> cProfile.run('bits_strings(1000, 1000)')
- 2005004 function calls in 0.760 seconds
- Ordered by: standard name
- ncalls tottime percall cumtime percall filename:lineno(function)
- 1 0.000 0.000 0.760 0.760 <stdin>:1(bits_strings)
- 1000 0.001 0.000 0.757 0.001 <stdin>:1(chrs)
- 1001000 0.579 0.000 0.663 0.000 <stdin>:2(<genexpr>)
- 1 0.000 0.000 0.761 0.761 <string>:1(<module>)
- 1000000 0.084 0.000 0.084 0.000 {chr}
- 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
- 1000 0.003 0.000 0.003 0.000 {method 'getrandbits' of '_random.Random' objects}
- 1000 0.088 0.000 0.751 0.001 {method 'join' of 'str' objects}
- 1001 0.004 0.000 0.004 0.000 {range}
- >>> def chrs(bits, len_string):
- ... return ''.join(chr((bits >> (8*x)) & 0xff) for x in range(len_string))
- ...
- >>> def bits_strings(num_strings, len_string):
- ... return list(chrs(random.getrandbits(len_string*8), len_string) for x in range(num_strings))
- ...
- >>> cProfile.run('bits_strings(1000, 1000)')
- 1005005 function calls in 0.181 seconds
- Ordered by: standard name
- ncalls tottime percall cumtime percall filename:lineno(function)
- 1 0.000 0.000 0.751 0.751 <stdin>:1(bits_strings)
- 1000 0.001 0.000 0.747 0.001 <stdin>:1(chrs)
- 1001 0.001 0.000 0.751 0.001 <stdin>:2(<genexpr>)
- 1 0.000 0.000 0.751 0.751 <string>:1(<module>)
- 1000000 0.085 0.000 0.085 0.000 {chr}
- 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
- 1000 0.003 0.000 0.003 0.000 {method 'getrandbits' of '_random.Random' objects}
- 1000 0.087 0.000 0.742 0.001 {method 'join' of 'str' objects}
- 1001 0.004 0.000 0.004 0.000 {range}
Advertisement
Add Comment
Please, Sign In to add comment