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 data = {
valuea: 123,
valueb: null,
valuec: 'ads',
valued: undefined,
valuee: '',
valuef: 3456,
valueg: 123,
valueh: null,
valuei: 'ads',
valuej: undefined,
valuek: '',
valuel: 3456
}
function cleanResponse(response, requiredFields = []) {
return Object.fromEntries(
Object.entries(response)
.filter(([key, value]) => value != null || requiredFields.includes(key))
.map(([key, value]) => [
key,
value && typeof value === 'object' && !Array.isArray(value) ? cleanResponse(value, requiredFields) : value,
])
);
}
function cleanResponseNew(response, requiredFields = []) {
return Object.entries(response).reduce((acc, [key, value]) => {
if (value != null || requiredFields.includes(key)) {
acc[key] = value && typeof value === 'object' && !Array.isArray(value) ? cleanResponse(value, requiredFields) : value;
}
return acc;
}
, {});
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Original |
| ready |
Optimized |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.