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
compares parsing a full object using JSON vs only object values and transforming back to object using an schema
// Define schema and sample data
const userSchema = {
name: 'string',
surname: 'string',
phone: 'string',
email: 'string',
id: 'string',
lastUpdate: 'string',
};
const jsonString = '{"name": "John", "surname": "Smith", "phone": "123456789", "email": "john@example.com", "id": "123", "lastUpdate": "2023-01-01"}';
const dataArrayString = '["John", "Smith", "123456789", "john@example.com", "123", "2023-01-01"]';
// Function to transform array to object
function arrayToObject(dataArray, schema) {
const result = {};
Object.keys(schema).forEach((key, index) => {
result[key] = dataArray[index];
});
return result;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
parsing full js object |
| ready |
parsing only values + transform into object |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.