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 o = {
a: 123,
b: undefined,
c: 123,
d: undefined
}
function filterUndefined_delete_in(obj) {
for (const key in obj) {
if (obj[key] === undefined) delete obj[key];
}
return obj
}
function filterUndefined_delete_of_keys(obj) {
for (const key of Object.keys(obj)) {
if (obj[key] === undefined) delete obj[key];
}
return obj
}
function filterUndefined_delete_of_entries(obj) {
for (const key of Object.keys(obj)) {
if (obj[key] === undefined) delete obj[key];
}
return obj
}
function filterUndefined_filter_entries(obj) {
// $FlowIgnore
return Object.fromEntries(
// $FlowIgnore
Object.entries(obj).filter(([_k, v]) => v !== undefined),
);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
for in delete |
| ready |
filter entries |
| ready |
for of keys |
| ready |
for of entries |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.