Roll leveldb 3f7758:803d69 (v1.17 -> v1.18)
[chromium-blink-merge.git] / chrome / test / data / dromaeo / tests / sunspider-access-binary-trees.html
blobd0c8777c9438606b1402db2ff8d43b0892b81772
1 <html>
2 <head>
3 <script src="../htmlrunner.js"></script>
4 <script>
5 /* The Great Computer Language Shootout
6 http://shootout.alioth.debian.org/
7 contributed by Isaac Gouy */
9 function TreeNode(left,right,item){
10 this.left = left;
11 this.right = right;
12 this.item = item;
15 TreeNode.prototype.itemCheck = function(){
16 if (this.left==null) return this.item;
17 else return this.item + this.left.itemCheck() - this.right.itemCheck();
20 function bottomUpTree(item,depth){
21 if (depth>0){
22 return new TreeNode(
23 bottomUpTree(2*item-1, depth-1)
24 ,bottomUpTree(2*item, depth-1)
25 ,item
28 else {
29 return new TreeNode(null,null,item);
33 window.onload = function(){ startTest("sunspider-access-binary-trees", 'c1dfeea3');
35 var ret;
37 test( "Binary Trees", function(){
38 for ( var n = 4; n <= 5; n += 1 ) {
39 var minDepth = 4;
40 var maxDepth = Math.max(minDepth + 2, n);
41 var stretchDepth = maxDepth + 1;
43 var check = bottomUpTree(0,stretchDepth).itemCheck();
45 var longLivedTree = bottomUpTree(0,maxDepth);
46 for (var depth=minDepth; depth<=maxDepth; depth+=2){
47 var iterations = 1 << (maxDepth - depth + minDepth);
49 check = 0;
50 for (var i=1; i<=iterations; i++){
51 check += bottomUpTree(i,depth).itemCheck();
52 check += bottomUpTree(-i,depth).itemCheck();
56 ret = longLivedTree.itemCheck();
58 });
60 endTest(); };
61 </script>
62 </head>
63 <body></body>
64 </html>