1
0
forked from Mirror/wren

Add JavaScript to benchmark runner.

This commit is contained in:
Bob Nystrom
2013-11-26 07:50:12 -08:00
parent af6b73208c
commit af694053a5
2 changed files with 15 additions and 1 deletions

13
benchmark/fib.js Normal file
View File

@ -0,0 +1,13 @@
function fib(n) {
if (n < 2) return n;
return fib(n - 1) + fib(n - 2);
}
var start = process.hrtime();
var i = 0;
for (var i = 0; i < 5; i++) {
console.log(fib(30));
}
var elapsed = process.hrtime(start);
elapsed = elapsed[0] + elapsed[1] / 1000000000;
console.log("elapsed: " + elapsed);

View File

@ -20,7 +20,8 @@ LANGUAGES = [
("wren", "../build/Release/wren", ".wren"),
("lua", "lua", ".lua"),
("python", "python", ".py"),
("ruby", "ruby", ".rb")
("ruby", "ruby", ".rb"),
("js", "node", ".js")
]
# How many times to run a given benchmark. Should be an odd number to get the