Lox

 view release on metacpan or  search on metacpan

test/benchmark/binary_trees.lox  view on Meta::CPAN


var start = clock();

print "stretch tree of depth:";
print stretchDepth;
print "check:";
print Tree(0, stretchDepth).check();

var longLivedTree = Tree(0, maxDepth);

// iterations = 2 ** maxDepth
var iterations = 1;
var d = 0;
while (d < maxDepth) {
  iterations = iterations * 2;
  d = d + 1;
}

var depth = minDepth;
while (depth < stretchDepth) {
  var check = 0;
  var i = 1;
  while (i <= iterations) {
    check = check + Tree(i, depth).check() + Tree(-i, depth).check();
    i = i + 1;
  }

  print "num trees:";
  print iterations * 2;
  print "depth:";
  print depth;
  print "check:";
  print check;

  iterations = iterations / 4;
  depth = depth + 2;
}

print "long lived tree of depth:";
print maxDepth;
print "check:";
print longLivedTree.check();
print "elapsed:";
print clock() - start;



( run in 0.644 second using v1.01-cache-2.11-cpan-71847e10f99 )