Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
jsondb + msgpack
var arr = [],
obj = {'abcdef' : 1, 'qqq' : 13, '19' : [1, 2, 3, 4]};
for(var i = 0; i < 5000; i++)
arr.push(obj);
// jsondb(arr) looks something like this:
// ["abcdef", "qqq", "19", [1, 13, [1, 2, 3, 4]], [1, 13, [1, 2, 3, 4]]...]
> JSON.stringify(arr).length //original
> 185001
> JSON.stringify(jsondb(arr)).length //jsondb
> 85030 // 54% size decrease
> MsgPack.pack(arr).length // just msgpack
> 110003 // 40% size decrease
> MsgPack.pack(jsondb(arr)).length // msgpack + jsondb
> 40024 // 78% size decrease
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.