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 result1 = {
politeness: 0,
resolution: 0,
grammar: 0,
customerSatisfaction: 0,
};
const dataAvg = (d) => d.reduce((acc, obj) => {
(Object.keys(obj)).forEach((key) => {
if (key === "inquiry") {
return;
}
acc[key] = (acc[key] + obj[key]) / d.length;
});
return acc;
}, result1);
function getMostConsistentObject(data) {
const result = {
politeness: 0,
resolution: 0,
grammar: 0,
customerSatisfaction: 0,
};
data.forEach((obj) => {
(Object.keys(obj)).forEach((key) => {
if (key !== "inquiry") {
if (!result[key]) {
result[key] = 0;
}
result[key] += obj[key];
}
});
});
(Object.keys(result)).forEach((key) => {
result[key] = Math.round(result[key] / data.length);
});
return result;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
With reduce |
| ready |
With foreach |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.