Sha256: 9dd7ee368d9479dd6937633614de73db276125657cbd0b82e84d277454eca305

Contents?: true

Size: 1.5 KB

Versions: 33

Compression:

Stored size: 1.5 KB

Contents

var msgpack = require('node-msgpack');
var bison = require('bison');
var codec = {
	JSON: {
		encode: JSON.stringify,
		decode: JSON.parse
	},
	msgpack: {
		encode: msgpack.pack,
		decode: msgpack.unpack
	},
	bison: bison
};

var obj, l;

var s = '0';
for (var i = 0; i < 12; ++i) s += s;

obj = {
	foo: s,
	arrrrrr: [{a:1,b:false,c:null,d:1.0}, 1111, 2222, 33333333],
	rand: [],
	a: s,
	ccc: s,
	b: s + s + s
};
for (i = 0; i < 100; ++i) obj.rand.push(Math.random());
forObj(obj);

obj = {
	foo: s,
	arrrrrr: [{a:1,b:false,c:null,d:1.0}, 1111, 2222, 33333333],
	rand: []
};
for (i = 0; i < 100; ++i) obj.rand.push(Math.random());
forObj(obj);

obj = {
	foo: s,
	arrrrrr: [{a:1,b:false,c:null,d:1.0}, 1111, 2222, 33333333],
	rand: []
};
forObj(obj);

obj = {
	arrrrrr: [{a:1,b:false,c:null,d:1.0}, 1111, 2222, 33333333],
	rand: []
};
forObj(obj);

function run(obj, codec) {
	var t1 = Date.now();
	var n = 10000;
	for (var i = 0; i < n; ++i) {
		codec.decode(l = codec.encode(obj));
	}
	var t2 = Date.now();
	//console.log('DONE', n*1000/(t2-t1), 'codecs/sec, length=', l.length);
	return [n*1000/(t2-t1), l.length];
}

function series(obj, cname, n) {
	var rate = 0;
	var len = 0;
	for (var i = 0; i < n; ++i) {
		var r = run(obj, codec[cname]);
		rate += r[0];
		len += r[1];
	}
	rate /= n;
	len /= n;
	console.log(cname + '	' + rate + '	' + len);
	return [rate, len];
}

function forObj(obj) {
	var r = {
		JSON: series(obj, 'JSON', 20),
		msgpack: series(obj, 'msgpack', 20),
		bison: series(obj, 'bison', 20)
	};
	return r;
}

Version data entries

33 entries across 33 versions & 4 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
hooch-0.4.1 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
hooch-0.4.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
hooch-0.3.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
hooch-0.2.1 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
hooch-0.2.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
hooch-0.1.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
hooch-0.0.8 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
hooch-0.0.7 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
hooch-0.0.6 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
entangled-0.0.16 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
entangled-0.0.15 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
entangled-0.0.14 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
entangled-0.0.13 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
entangled-0.0.12 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
entangled-0.0.11 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
entangled-0.0.10 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/redis/benches/stress/speed/speed.js
express_translate-1.0.13 node_modules/redis/benches/stress/speed/speed.js
express_translate-1.0.12 node_modules/redis/benches/stress/speed/speed.js
express_translate-1.0.11 node_modules/redis/benches/stress/speed/speed.js