jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Comparing Fibonacci algorithms: for loops and recursive ones.
const fibonacciForLoop = (n) => {
let result = [];
for (let i = 0; i < n; i++) {
if (i === 0) {
result.push(0);
} else if (i === 1) {
result.push(1);
} else {
result.push(result[i - 1] + result[i - 2]);
}
}
return result.at(-1);
};
const fibonacciRecursive = function fib(n) {
if (n === 0) {
return 0;
} else if (n === 1) {
return 1;
} else {
return fib(n - 1) + fib(n - 2);
}
};Ready to run.
| Test | Ops/sec | |
|---|---|---|
| for | | ready |
| recursive | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.