Skip to content

Instantly share code, notes, and snippets.

@dshaw
Forked from devongovett/gist:1037265
Created August 15, 2011 04:01
Show Gist options
  • Save dshaw/1145696 to your computer and use it in GitHub Desktop.
Save dshaw/1145696 to your computer and use it in GitHub Desktop.
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