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
<script>
const objectSize = (obj) => {
return JSON.stringify(obj).length
}
const objectSizeEstimate = (obj) => {
if (typeof obj === 'object' && obj !== null) {
let sum = 0;
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
sum += key.length;
sum += objectSizeEstimate(obj[key]);
}
}
return sum
}
if (typeof obj === 'string') {
return obj.length
}
return 4;
}
let obj = {
"result": [
{
"message": "Hello, Nolan! Your order number is: #53",
"phoneNumber": "(879) 768-4088 x338",
"phoneVariation": "+90 318 130 10 27",
"status": "active",
"name": {
"first": "Mekhi",
"middle": "Skyler",
"last": "Mante"
},
"username": "Mekhi-Mante",
"password": "6HsHlcI1XSrQdK2",
"emails": [
"Nathan_Aufderhar@example.com",
"Kianna.Stiedemann15@example.com"
],
"location": {
"street": "420 The Causeway",
"city": "Gottliebstead",
"state": "Delaware",
"country": "Niue",
"zip": "17035",
"coordinates": {
"latitude": "-1.5848",
"longitude": "149.8544"
}
},
"website": "https://jubilant-classroom.info",
"domain": "honest-classmate.biz",
"job": {
"title": "National Branding Orchestrator",
"descriptor": "Legacy",
"area": "Paradigm",
"type": "Coordinator",
"company": "Senger and Sons"
},
"creditCard": {
"number": "4635048783160",
"cvv": "685",
"issuer": "maestro"
},
"uuid": "08092f0c-9957-4dcf-92ef-d886d9137efe",
"objectId": "66d18419c6758160f2ab9b0d"
}
]
};
let largeObj = {
arr: [
{...obj},
{...obj},
{...obj},
{...obj},
{...obj},
{...obj},
{...obj},
{...obj},
],
}
</script>
obj.r = Math.random()
largeObj.r = Math.random()
Ready to run.
Test | Ops/sec | |
---|---|---|
JSON.stringify |
| ready |
estimate |
| ready |
JSON.stringify large |
| ready |
estimate large |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.