mcollina / msgpack5

A msgpack v5 implementation for node.js, with extension points / msgpack.org[Node]
MIT License
493 stars 76 forks source link

Add benchmark results compared to JSON to README? #73

Open brandonros opened 6 years ago

brandonros commented 6 years ago

encodedecode_json.js

var msg = { hello: 'world' }
var encode = JSON.stringify
var decode = JSON.parse
var max = 100000
var start
var stop
var i

function run () {
  for (i = 0; i < max; i++) {
    decode(encode(msg))
  }
}

// preheat
run()

start = Date.now()
run()
stop = Date.now()
console.log('time', stop - start)
console.log('decode/s', max / (stop - start) * 1000)
$ node encodedecode_json.js
time 79
decode/s 1265822.7848101268

compared to

$ node encodedecode.js 
time 1594
decode/s 62735.25721455458

Am I misunderstanding something?...

vnoder commented 5 years ago

Me too

thephoenixofthevoid commented 5 years ago

JSON methods are native functions heavily micro-optimized by browser vendors/nodejs C++ devs. It's very difficult to come up with something faster written purely in js, but relatively easy --- with something better: extensible, compact and supporting more types out of box.

nguyenquyhy commented 4 years ago

Really hope there is some maintained benchmark (esp. comparing to JSON) for this project. It is very hard to decide without knowing the circumstances that MessagePack is actually better than JSON.