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
Which is faster? Array.filter or for..of..if
let counter = 0;
const largeData = Array.from({ length: 10_000 }, () => counter++);
const largeDataSet = new Set(largeData);
const isEven = (num) => num % 2 === 0;
function arrayTest(data) {
return data.filter(isEven);
}
function *generatorTest(data) {
for (let num of data)
if (isEven(num)) yield num;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Array.filter with array |
| ready |
Generator with array |
| ready |
Array.filter with set |
| ready |
Generator with set |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.