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
const as = [];
for (let i = 0; i < 1000; i++) {
as.push(i);
}
function keep(arr, f) {
return arr.map(f).filter((b) => b !== null);
}
function keep2(arr, f) {
return arr.reduce((result, a) => {
const b = f(a);
if (b !== null) {
result.push(b);
}
return result;
}, []);
}
function keep3(arr, f) {
const result = [];
for (const a of arr) {
const b = f(a);
if (b !== null) {
result.push(b);
}
}
return result;
}
function mogrify(x) {
const r = Math.random();
if (r > 0) {
return x + (x * r);
} else {
return null;
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
map + filter |
| ready |
reduce |
| ready |
for/of |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.