Last active
October 27, 2015 02:00
-
-
Save okkez/2b77b32ad3a966446347 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var msgpack5 = require('msgpack5')(); | |
var msgpack = require('msgpack'); | |
var msgpackLite = require('msgpack-lite'); | |
var obj = { | |
a: 1, | |
b: 'aaaaaaaaaa', | |
c: true, | |
}; | |
var TIMES = 10000; | |
var packed, unpacked; | |
console.time('msgpack5'); | |
for (var i = 0; i < TIMES; i++) { | |
packed = msgpack5.encode(obj); | |
//unpacked = msgpack5.decode(packed); | |
} | |
console.timeEnd('msgpack5'); | |
console.time('msgpack'); | |
for (var i = 0; i < TIMES; i++) { | |
packed = msgpack.pack(obj); | |
//unpacked = msgpack.unpack(packed); | |
} | |
console.timeEnd('msgpack'); | |
console.time('msgpack-lite'); | |
for (var i = 0; i < TIMES; i++) { | |
packed = msgpackLite.encode(obj); | |
} | |
console.timeEnd('msgpack-lite'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ node ./benchmark.js | |
msgpack5: 821ms | |
msgpack: 36ms | |
msgpack-lite: 23ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment