You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?...
The text was updated successfully, but these errors were encountered:
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.
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.
encodedecode_json.js
compared to
Am I misunderstanding something?...
The text was updated successfully, but these errors were encountered: