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 users = [
{ name: 'Alice', gentle: 'female' },
{ name: 'Bob', gentle: 'male' },
{ name: 'Charlie', gentle: 'male' },
{ name: 'Eve', gentle: 'female' }
];
function groupBy(array, keySelector) {
const group = {};
for (const element of array) {
const key = keySelector(element);
if (!group[key]) {
group[key] = [];
}
group[key].push(element);
}
return group;
}
function groupBy2(array, predicate) {
return array.reduce((acc, value, index, array) => {
const key = predicate(value, index, array)
if (!acc[key])
acc[key] = []
acc[key].push(value)
return acc
})
}
Ready to run.
Test | Ops/sec | |
---|---|---|
for...of |
| ready |
Object.groupBy |
| ready |
groupBy2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.