/mobile Handheld Friendly website
Ubuntu : Intel® Q6600® quad-core |
Each table row shows performance measurements for this Python 3 program with a particular command-line input value N.
| N | CPU secs | Elapsed secs | Memory KB | Code B | ≈ CPU Load |
|---|---|---|---|---|---|
| 12 | 0.98 | 0.38 | 18,924 | 626 | 62% 62% 81% 66% |
| 16 | 21.99 | 6.03 | 66,200 | 626 | 90% 96% 92% 89% |
| 20 | 524.47 | 139.16 | 685,880 | 626 | 98% 93% 93% 93% |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read binary-trees benchmark to see what this program should do.
Python 3.3.1 (default, Apr 11 2013, 12:56:47) [GCC 4.7.2] on linux
# The Computer Language Benchmarks Game # http://benchmarksgame.alioth.debian.org/ # # contributed by Antoine Pitrou # modified by Dominique Wahli and Daniel Nanz from __future__ import print_function import sys import multiprocessing as mp def make_tree(i, d): if d > 0: i2 = i + i d -= 1 return (i, make_tree(i2 - 1, d), make_tree(i2, d)) return (i, None, None) def check_tree(node): (i, l, r) = node if l is None: return i else: return i + check_tree(l) - check_tree(r) def make_check(itde, make=make_tree, check=check_tree): i, d = itde return check(make(i, d)) def get_argchunks(i, d, chunksize=5000): assert chunksize % 2 == 0 chunk = [] for k in range(1, i + 1): chunk.extend([(k, d), (-k, d)]) if len(chunk) == chunksize: yield chunk chunk = [] if len(chunk) > 0: yield chunk def main(n, min_depth=4): max_depth = max(min_depth + 2, n) stretch_depth = max_depth + 1 if mp.cpu_count() > 1: pool = mp.Pool() chunkmap = pool.map else: chunkmap = map print('stretch tree of depth {0}\t check: {1}'.format( stretch_depth, make_check((0, stretch_depth)))) long_lived_tree = make_tree(0, max_depth) mmd = max_depth + min_depth for d in range(min_depth, stretch_depth, 2): i = 2 ** (mmd - d) cs = 0 for argchunk in get_argchunks(i,d): cs += sum(chunkmap(make_check, argchunk)) print('{0}\t trees of depth {1}\t check: {2}'.format(i * 2, d, cs)) print('long lived tree of depth {0}\t check: {1}'.format( max_depth, check_tree(long_lived_tree))) if __name__ == '__main__': main(int(sys.argv[1]))
Thu, 11 Apr 2013 21:29:05 GMT MAKE: mv binarytrees.python3-6.python3 binarytrees.python3-6.py 0.03s to complete and log all make actions COMMAND LINE: /usr/local/src/Python-3.3.1/bin/python3.3 binarytrees.python3-6.py 20 PROGRAM OUTPUT: stretch tree of depth 21 check: -1 2097152 trees of depth 4 check: -2097152 524288 trees of depth 6 check: -524288 131072 trees of depth 8 check: -131072 32768 trees of depth 10 check: -32768 8192 trees of depth 12 check: -8192 2048 trees of depth 14 check: -2048 512 trees of depth 16 check: -512 128 trees of depth 18 check: -128 32 trees of depth 20 check: -32 long lived tree of depth 20 check: -1