feat: add JavaScript benchmark runner with fib(30) test and node integration
Add a new JavaScript benchmark file `benchmark/fib.js` that implements a recursive Fibonacci function and measures execution time using `process.hrtime()`. Register the JavaScript language entry in `benchmark/run_all` with the `node` interpreter and `.js` extension, enabling JS benchmarks to be included in the full benchmark suite alongside existing languages.
This commit is contained in:
@@ -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);
|
||||
Reference in New Issue
Block a user