Last active
August 29, 2015 14:27
-
-
Save yukidarake/5865984f2eb856c3dd6d to your computer and use it in GitHub Desktop.
Node.jsで使えるMessagePackライブラリのベンチマークをとってみた
This file contains hidden or 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'); | |
require("uupaa.messagepack.js/lib/WebModule.js"); | |
require("uupaa.messagepack.js/lib/MessagePack.js"); | |
var uupaa = WebModule.MessagePack; | |
var msgpackjs = require('msgpack-js'); | |
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('uupaa'); | |
for (var i = 0; i < TIMES; i++) { | |
packed = uupaa.encode(obj); | |
unpacked = uupaa.decode(packed); | |
} | |
console.timeEnd('uupaa'); | |
console.time('msgpackjs'); | |
for (var i = 0; i < TIMES; i++) { | |
packed = msgpackjs.encode(obj); | |
unpacked = msgpackjs.decode(packed); | |
} | |
console.timeEnd('msgpackjs'); | |
console.time('json'); | |
for (var i = 0; i < TIMES; i++) { | |
packed = JSON.stringify(obj); | |
unpacked = JSON.parse(packed); | |
} | |
console.timeEnd('json'); |
This file contains hidden or 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
# 結果 | |
msgpack5: 2456ms | |
msgpack: 87ms | |
uupaa: 118ms | |
msgpackjs: 178ms | |
json: 11ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment