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 keys = ["hello", "world", "wow", "this", "is", "fun"];
const values = [];
for (let i = 0; i < 100_000; i++) {
values.push([keys[Math.floor(Math.random() * keys.length)], i]);
}
function groupByFor(iter) {
const result = {};
for (const value of iter) {
const entry = (result[value[0]] ||= []);
entry.push(value);
}
return result;
}
function groupByReduce(iter) {
return iter.reduce((result, value) => {
const entry = (result[value[0]] ||= []);
entry.push(value);
return result
}, {});
}
Ready to run.
Test | Ops/sec | |
---|---|---|
reduce |
| ready |
for loop |
| ready |
Object.groupBy |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.