var adcloud = require("./index");

var coder = require("./lib/coder");
var app_msg = require("./lib/app_message");
var obj = {
     a:10900,
	b:"dsfsdfsdfdsf"
};
var str = JSON.stringify(obj);

var buf = new Buffer(Buffer.byteLength(str));
var msg = new app_msg.MAppClientData(123,buf);
console.log(buf.length)
var num = process.argv[2];
if(!num) num = 1;
var size = msg.Length() * num;

var buf_writer = new coder.BufferWriter(size);
console.time("a");
for(var i=0;i<num;i++){
	msg.Encode(buf_writer);
}
console.timeEnd("a");
var pkt = {obj:obj,cmd:"msg"};
console.time("b");
for(var i=0;i<num;i++){
	JSON.stringify(pkt)
}
console.timeEnd("b");