0rpc / zerorpc-node

zerorpc for node.js
http://www.zerorpc.io
Other
704 stars 166 forks source link

Replacing msgpack with msgpack-light? #86

Closed stanleyxu2005 closed 6 years ago

stanleyxu2005 commented 7 years ago

According to the benchmark sheet, the pure js implementation is even faster than node-gyp built version.

Futhermore, it would be great to specify the message encoding protocol by user choice. If the RPC is only on the same machine, performance difference of JSON or msgpack might not be huge. I read some notes that Nodejs has pretty much improved the performance of encoding JSON.

Benchmarks

A benchmark tool lib/benchmark.js is available to compare encoding/decoding speed (operation per second) with other MessagePack modules. It counts operations of 1KB JSON document in 10 seconds.

$ npm install msgpack msgpack-js msgpack-js-v5 msgpack-unpack msgpack5 notepack
$ npm run benchmark 10
operation op ms op/s
buf = Buffer(JSON.stringify(obj)); 1055200 10000 105520
obj = JSON.parse(buf); 863800 10000 86380
buf = require("msgpack-lite").encode(obj); 969100 10000 96910
obj = require("msgpack-lite").decode(buf); 600300 10000 60030
buf = require("msgpack").pack(obj); 503500 10001 50344
obj = require("msgpack").unpack(buf); 560200 10001 56014
bombela commented 7 years ago

nice work, I will find some time this week to read all the details and look at your PR.