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
fibonacci using iterator protocol.
<script>
const fibonacciIterator = (n) => {
let i = 1;
let [prev, cur] = [0n, 1n];
return {
[Symbol.iterator]() {
return this;
},
next() {
if (n === 0) {
return 0;
}
[prev, cur] = [cur, prev+cur];
return { value: cur, done: i++ === n };
}
}
};
function fibonacci_iterator(n) {
let answer = 0n;
for (const x of fibonacciIterator(n)) {
answer = x % 1234567n;
}
return answer;
}
function fibonacci_array(num) {
let fibo = [0n, 1n];
for(let i = 2; i <= num; i++){
fibo[i] = fibo[i-1] + fibo[i-2];
}
return fibo[num];
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
find 100,000th fibo using iterator |
| ready |
find 100,000th fibo using array |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.