performance measurements

Each table row shows performance measurements for this Hack program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
120.290.29548468  84% 3% 11% 0%
163.253.2576,164468  0% 1% 100% 1%
2066.4466.53385,236468  100% 1% 1% 0%

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

HipHop VM 3.0.0-dev (rel)
Compiler: heads/master-0-g7fe20173f182c6f8363c3f1752da50aa16c674df
Repo schema: daaf94930cc75e7b0cb2b11779a1be66280a5b6c

 binary-trees Hack #2 program source code

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

   contributed by Peter Baltruschat
   modified by Levi Cameron
   modified by Craig Russell
   PHP as HHVM/Hack by Isaac Gouy
*/

class Tree {
   public $i;
   public $l;
   public $r;
   
   public function __construct($item, $depth) {
      $this->i = $item;
      if($depth) {
         $this->l = new Tree($item * 2 - 1, --$depth);
         $this->r = new Tree($item * 2, $depth);
      }
   }
   
   public function check() {
      return $this->i
         + ($this->l->l === null ? $this->l->check() : $this->l->i)
         - ($this->r->l === null ? $this->r->check() : $this->r->i);
   }
}

$minDepth = 4;

$n = $argc == 2 ? $argv[1] : 1;
$maxDepth = $minDepth + 2 > $n ? $minDepth + 2 : $n;
$stretchDepth = $maxDepth + 1;

$stretch = new Tree(0, $stretchDepth);
printf("stretch tree of depth %d\t check: %d\n",
   $stretchDepth, $stretch->check());
unset($stretch);

$longLivedTree = new Tree(0, $maxDepth);

$iterations = 1 << $maxDepth;
do
{
   $check = 0;
   for($i = 1; $i <= $iterations; ++$i)
   {
      $check += (new Tree($i, $minDepth))->check()
         + (new Tree(-$i, $minDepth))->check();
   }
   
   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, $longLivedTree->check());

 make, command-line, and program output logs

Sat, 29 Mar 2014 02:12:14 GMT

COMMAND LINE:
/usr/local/src/hhvmdev/hhvm/hphp/hhvm/hhvm  binarytrees.hack-2.hack 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

Revised BSD license

  Home   Conclusions   License   Play