mirror of
https://github.com/MorizzG/MLox.git
synced 2025-12-06 12:32:41 +00:00
added lox test files
This commit is contained in:
parent
821f5c62bc
commit
0f3d0a15f0
268 changed files with 7497 additions and 3 deletions
31
lox.t/benchmark/zoo.lox
Normal file
31
lox.t/benchmark/zoo.lox
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
class Zoo {
|
||||
init() {
|
||||
this.aarvark = 1;
|
||||
this.baboon = 1;
|
||||
this.cat = 1;
|
||||
this.donkey = 1;
|
||||
this.elephant = 1;
|
||||
this.fox = 1;
|
||||
}
|
||||
ant() { return this.aarvark; }
|
||||
banana() { return this.baboon; }
|
||||
tuna() { return this.cat; }
|
||||
hay() { return this.donkey; }
|
||||
grass() { return this.elephant; }
|
||||
mouse() { return this.fox; }
|
||||
}
|
||||
|
||||
var zoo = Zoo();
|
||||
var sum = 0;
|
||||
var start = clock();
|
||||
while (sum < 10000000) {
|
||||
sum = sum + zoo.ant()
|
||||
+ zoo.banana()
|
||||
+ zoo.tuna()
|
||||
+ zoo.hay()
|
||||
+ zoo.grass()
|
||||
+ zoo.mouse();
|
||||
}
|
||||
|
||||
print sum;
|
||||
print clock() - start;
|
||||
Loading…
Add table
Add a link
Reference in a new issue