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
"use strict";
const notificationFields = ['foo', 'bar', 'baz', 'quux'];
const data = {
foo: { value: true },
bar: { value: false },
baz: { value: true },
quux: { value: false },
};
function getNotificationChannelCount1() {
return notificationFields.reduce((count, fieldName) => {
if (data[fieldName].value) {
count += 1;
}
return count;
}, 0);
}
function getNotificationChannelCount2() {
let count = 0;
for (const fieldName of notificationFields) {
if (data[fieldName].value) {
count += 1;
}
}
return count;
}
function getNotificationChannelCount3() {
let count = 0;
for (let i = 0; i < notificationFields.length; i++) {
if (data[notificationFields[i]].value) {
count += 1;
}
}
return count;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Reduce |
| ready |
for-of |
| ready |
for i |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.