Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: msgpack-lite is much more efficient for large strings #104

Open
D1plo1d opened this issue Jun 26, 2019 · 1 comment
Open

docs: msgpack-lite is much more efficient for large strings #104

D1plo1d opened this issue Jun 26, 2019 · 1 comment

Comments

@D1plo1d
Copy link

D1plo1d commented Jun 26, 2019

Just to note, MsgPack-lite is much better then JSON at large strings. If you add a 1.9MB string to the benchmark data you can really start to see an advantage in msgpack-lite's favor. Here's the results I got before the benchmark crashed:

$ ./lib/benchmark.js
operation                                                 |   op   |   ms  |  op/s 
--------------------------------------------------------- | -----: | ----: | -----:
buf = Buffer(JSON.stringify(obj));                        |    100 |  8776 |     11
obj = JSON.parse(buf);                                    |    100 |  6773 |     14
buf = require("msgpack-lite").encode(obj);                |  18000 |  5004 |   3597
obj = require("msgpack-lite").decode(buf);                |  19400 |  5026 |   3859
/home/d1plo1d/git_repos/msgpack-lite/node_modules/msgpack.codec/msgpack.codec.js:204
                Array.prototype.push.apply(rv, mix);
                                     ^

RangeError: Maximum call stack size exceeded

PS. I know 1.9MB is huge, it's a really out there edge case. I am using msgpack-lite to serializing file uploads over WebRTC data channels so for me this is a real world use case and MsgPack totally rocks it!

@D1plo1d
Copy link
Author

D1plo1d commented Jun 26, 2019

My results were based on a quick hack at the top of the benchmark:

var data = require("../test/example");
var fs = require("fs");
var longString = fs.readFileSync("/some_directory/benchy.gcode");
data.longString = longString

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant