Skip to content

Instantly share code, notes, and snippets.

@yukidarake yukidarake/msgpack.js
Last active Aug 29, 2015

Embed
What would you like to do?
Node.jsで使えるMessagePackライブラリのベンチマークをとってみた
'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');
# 結果
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
You can’t perform that action at this time.