creationix / msgpack-js

The msgpack protocol implemented in pure javascript.
http://msgpack.org/
MIT License
253 stars 48 forks source link

As with "The Other msgpack module" -- performance seems to be lower than JSON. #6

Open bingomanatee opened 11 years ago

bingomanatee commented 11 years ago

https://www.dropbox.com/s/b9daq3hfald2tee/6.bin

is my binary file

and

https://www.dropbox.com/s/1l4f8i5dp7q5iz0/6.json

is my JSON file.

The message pack version seems like it is half as big but takes twice as long to parse.

--- Want to back this issue? **[Place a bounty on it!](https://www.bountysource.com/issues/969341-as-with-the-other-msgpack-module-performance-seems-to-be-lower-than-json?utm_campaign=plugin&utm_content=tracker%2F133121&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F133121&utm_medium=issues&utm_source=github).
creationix commented 11 years ago

This is because it's hard to compete with the built-in json code in V8. Though it also depends on the kind of data you're parsing. Strings are the weak point here. Arrays of integers are super fast and compact. On Aug 8, 2013 4:04 PM, "Dave Edelhart" notifications@github.com wrote:

https://www.dropbox.com/s/b9daq3hfald2tee/6.bin

is my binary file

and

https://www.dropbox.com/s/1l4f8i5dp7q5iz0/6.json

is my JSON file.

The message pack version seems like it is half as big but takes twice as long to parse.

— Reply to this email directly or view it on GitHubhttps://github.com/creationix/msgpack-js/issues/6 .

bagbay-sav commented 10 years ago

There seems to be a significant difference in performance between 0.1.1 and 0.3.0 (sorry I didn't narrow it down more than that). I ran the benchmark.js from node-msgpack against node-msgpack, msgpack-js0.1.1 and msgpack-js0.3.0. Here are the results:

node-msgpack     pack:   2561 ms
node-msgpack     unpack: 8231 ms
msgpack-js 0.1.1 pack:   4474 ms
msgpack-js 0.1.1 unpack: 3120 ms
msgpack-js 0.3.0 pack:   16115 ms
msgpack-js 0.3.0 unpack: 6350 ms
json             pack:   4440 ms
json             unpack: 2217 ms

node-msgpack     pack:   4372 ms
node-msgpack     unpack: 8049 ms
msgpack-js 0.1.1 pack:   4626 ms
msgpack-js 0.1.1 unpack: 4071 ms
msgpack-js 0.3.0 pack:   16731 ms
msgpack-js 0.3.0 unpack: 6235 ms
json             pack:   3890 ms
json             unpack: 2674 ms

node-msgpack     pack:   3882 ms
node-msgpack     unpack: 8705 ms
msgpack-js 0.1.1 pack:   4474 ms
msgpack-js 0.1.1 unpack: 3782 ms
msgpack-js 0.3.0 pack:   16086 ms
msgpack-js 0.3.0 unpack: 5760 ms
json             pack:   3898 ms
json             unpack: 2686 ms

✔ benchmark - output above is from three runs on a 1m element array of objects

node-msgpack     pack:   7717 ms
node-msgpack     unpack: 2565 ms
msgpack-js 0.1.1 pack:   6102 ms
msgpack-js 0.1.1 unpack: 1707 ms
msgpack-js 0.3.0 pack:   16696 ms
msgpack-js 0.3.0 unpack: 4254 ms
json             pack:   1400 ms
json             unpack: 681 ms

node-msgpack     pack:   7684 ms
node-msgpack     unpack: 2546 ms
msgpack-js 0.1.1 pack:   6087 ms
msgpack-js 0.1.1 unpack: 1710 ms
msgpack-js 0.3.0 pack:   16249 ms
msgpack-js 0.3.0 unpack: 3911 ms
json             pack:   1386 ms
json             unpack: 686 ms

node-msgpack     pack:   7721 ms
node-msgpack     unpack: 2525 ms
msgpack-js 0.1.1 pack:   6098 ms
msgpack-js 0.1.1 unpack: 1721 ms
msgpack-js 0.3.0 pack:   16259 ms
msgpack-js 0.3.0 unpack: 3902 ms
json             pack:   1391 ms
json             unpack: 683 ms

✔ benchmark - output above is from three runs of 1m individual calls