/mobile Handheld Friendly website
x64 Ubuntu : Intel® Q6600® one core |
Each table row shows performance measurements for this PHP program with a particular command-line input value N.
| N | CPU secs | Elapsed secs | Memory KB | Code B | ≈ CPU Load |
|---|---|---|---|---|---|
| 12 | 0.94 | 0.94 | 6,460 | 504 | 0% 0% 1% 99% |
| 16 | 27.63 | 27.66 | 67,480 | 504 | 0% 0% 0% 100% |
| 20 | 706.34 | 707.97 | 1,028,668 | 504 | 0% 0% 0% 100% |
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.
PHP 5.4.11 (cli) (built: Jan 27 2013 11:28:24)
<?php /* The Computer Language Benchmarks Game http://benchmarksgame.alioth.debian.org/ contributed by Peter Baltruschat modified by Levi Cameron */ // see class Node { public $item; public $l; public $r; } function bottomUpTree($item, $depth) { $node = new Node(); $node->item = $item; if (!$depth) return $node; $item2 = $item + $item; $depth--; $node->l = bottomUpTree($item2-1,$depth); $node->r = bottomUpTree($item2,$depth); return $node; } function itemCheck($treeNode) { return $treeNode->item + ($treeNode->l->l === null ? itemCheck($treeNode->l) : $treeNode->l->item) - ($treeNode->r->l === null ? itemCheck($treeNode->r) : $treeNode->r->item); } $minDepth = 4; $n = ($argc == 2) ? $argv[1] : 1; $maxDepth = max($minDepth + 2, $n); $stretchDepth = $maxDepth + 1; $stretchTree = bottomUpTree(0, $stretchDepth); printf("stretch tree of depth %d\t check: %d\n", $stretchDepth, itemCheck($stretchTree)); unset($stretchTree); $longLivedTree = bottomUpTree(0, $maxDepth); $iterations = 1 << ($maxDepth); do { $check = 0; for($i = 1; $i <= $iterations; ++$i) { $t = bottomUpTree($i, $minDepth); $check += itemCheck($t); unset($t); $t = bottomUpTree(-$i, $minDepth); $check += itemCheck($t); unset($t); } printf("%d\t trees of depth %d\t check: %d\n", $iterations<<1, $minDepth, $check); $minDepth += 2; $iterations >>= 2; } while($minDepth <= $maxDepth); printf("long lived tree of depth %d\t check: %d\n", $maxDepth, itemCheck($longLivedTree));
Mon, 28 Jan 2013 07:40:28 GMT COMMAND LINE: /usr/local/src/php-5.4.11/bin/php -n -d memory_limit=2048M binarytrees.php 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