Skip to content

Instantly share code, notes, and snippets.

@invalidred
Created June 15, 2020 16:43
Show Gist options
  • Save invalidred/817f0ba64df8102fd01b51009a4d2845 to your computer and use it in GitHub Desktop.
Save invalidred/817f0ba64df8102fd01b51009a4d2845 to your computer and use it in GitHub Desktop.
200 productIds
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if(obj !== null && obj !== undefined) {
switch(typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':
bytes += obj.length * 2;
break;
case 'boolean':
bytes += 4;
break;
case 'object':
var objClass = Object.prototype.toString.call(obj).slice(8, -1);
if(objClass === 'Object' || objClass === 'Array') {
for(var key in obj) {
if(!obj.hasOwnProperty(key)) continue;
sizeOf(obj[key]);
}
} else bytes += obj.toString().length * 2;
break;
}
}
return bytes;
};
function formatByteSize(bytes) {
if(bytes < 1024) return bytes + " bytes";
else if(bytes < 1048576) return(bytes / 1024).toFixed(3) + " KiB";
else if(bytes < 1073741824) return(bytes / 1048576).toFixed(3) + " MiB";
else return(bytes / 1073741824).toFixed(3) + " GiB";
};
return formatByteSize(sizeOf(obj));
};
let query = {
and: [
{or: [
{ vertical: { is: 'SNEAKERS' }},
{ vertical: { is: 'HANDBAGS' }},
]},
{spread: { gt: 10 }},
{daysListed: { lt: 5 }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
{productId: { is: '32sdwer-23wdfwer-234sdsdl' }},
]
}
memorySizeOf(query) // 9.813KB
memorySizeOf(JSON.stringify(query)) // 19.3815 KB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment