Last active
September 29, 2015 21:48
-
-
Save owenallenaz/ff77fc98081708146495 to your computer and use it in GitHub Desktop.
Comparing object_sizeof and JSON.stringify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm: 34ms | |
json: 7ms | |
317780 307781 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var object_sizeof = require("object-sizeof"); | |
var obj = {}; | |
for(var i = 0; i < 10000; i++) { | |
obj[i] = { | |
i : i, | |
data : "aaa" | |
} | |
} | |
console.time("npm"); | |
var first = object_sizeof(obj); | |
console.timeEnd("npm"); | |
console.time("json"); | |
var second = JSON.stringify(obj).length; | |
console.timeEnd("json"); | |
console.log(first, second); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment