/mobile Handheld Friendly website

 performance measurements

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
121.101.1212,156483  0% 0% 2% 100%
1639.1439.19151,576483  0% 0% 0% 100%
20Failed  483   

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.

 notes

PHP 5.5.0 (cli) (built: Jun 25 2013 23:17:03)

 binary-trees PHP #3 program source code

<?php 
/* The Computer Language Benchmarks Game
   http://benchmarksgame.alioth.debian.org/

   contributed by Peter Baltruschat
   modified by Levi Cameron
*/

function bottomUpTree($item, $depth)
{
   if (!$depth) return array(null,null,$item);
   $item2 = $item + $item;
   $depth--;
   return array(
      bottomUpTree($item2-1,$depth),
      bottomUpTree($item2,$depth),
      $item);
}

function itemCheck($treeNode) { 
   return $treeNode[2]
      + ($treeNode[0][0] === null ? itemCheck($treeNode[0]) : $treeNode[0][2])
      - ($treeNode[1][0] === null ? itemCheck($treeNode[1]) : $treeNode[1][2]);
}

$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));
?>

 make, command-line, and program output logs

Wed, 26 Jun 2013 11:19:51 GMT

COMMAND LINE:
/usr/local/src/php-5.5.0/bin/php -n -d memory_limit=2048M binarytrees.php-3.php 20

PROGRAM FAILED 


PROGRAM OUTPUT:

Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 72 bytes) in /home/dunham/benchmarksgame/bench/binarytrees/binarytrees.php-3.php on line 15

Revised BSD license

  Home   Conclusions   License   Play