mirror of
https://github.com/MorizzG/MLox.git
synced 2025-12-06 04:22:41 +00:00
moved benchmark lox files to separate folder
This commit is contained in:
parent
b4e25ee561
commit
29431d0cdb
13 changed files with 344 additions and 302 deletions
|
|
@ -1,29 +0,0 @@
|
|||
class Tree {
|
||||
init(depth) {
|
||||
this.depth = depth;
|
||||
if (depth > 0) {
|
||||
this.a = Tree(depth - 1);
|
||||
this.b = Tree(depth - 1);
|
||||
this.c = Tree(depth - 1);
|
||||
this.d = Tree(depth - 1);
|
||||
this.e = Tree(depth - 1);
|
||||
}
|
||||
}
|
||||
|
||||
walk() {
|
||||
if (this.depth == 0) return 0;
|
||||
return this.depth
|
||||
+ this.a.walk()
|
||||
+ this.b.walk()
|
||||
+ this.c.walk()
|
||||
+ this.d.walk()
|
||||
+ this.e.walk();
|
||||
}
|
||||
}
|
||||
|
||||
var tree = Tree(8);
|
||||
var start = clock();
|
||||
for (var i = 0; i < 100; i = i + 1) {
|
||||
if (tree.walk() != 122068) print "Error";
|
||||
}
|
||||
print clock() - start;
|
||||
Loading…
Add table
Add a link
Reference in a new issue