clean up connection slightly & add initial bench

remotes/origin/master-produse
bmc 12 years ago
parent 835f71a76f
commit ca5c10a02f

@ -0,0 +1,17 @@
benchmark
starting simple-query-parsing
3703 ops/sec - (100/0.027)
7299 ops/sec - (1000/0.137)
8888 ops/sec - (10000/1.125)
8733 ops/sec - (10000/1.145)
8810 ops/sec - (10000/1.135)
8771 ops/sec - (10000/1.14)
starting prepared-statement-parsing
3846 ops/sec - (100/0.026)
7299 ops/sec - (1000/0.137)
7225 ops/sec - (10000/1.384)
7288 ops/sec - (10000/1.372)
7225 ops/sec - (10000/1.384)
7457 ops/sec - (10000/1.341)
done

@ -474,7 +474,7 @@ Connection.prototype.parseT = function(msg) {
msg.fieldCount = this.parseInt16();
var fields = [];
for(var i = 0; i < msg.fieldCount; i++){
fields[i] = this.parseField();
fields.push(this.parseField());
}
msg.fields = fields;
return msg;
@ -498,7 +498,11 @@ Connection.prototype.parseD = function(msg) {
var fields = [];
for(var i = 0; i < fieldCount; i++) {
var length = this.parseInt32();
fields[i] = (length === -1 ? null : this.readBytes(length));
var value = null;
if(length !== -1) {
value = this.readBytes(length);
}
fields.push(value);
}
msg.fieldCount = fieldCount;
msg.fields = fields;
@ -553,49 +557,35 @@ Connection.prototype.parseA = function(msg) {
};
Connection.prototype.parseGH = function (msg) {
msg.binary = Boolean(this.parseInt8());
var isBinary = this.buffer[this.offset] !== 0;
this.offset++;
msg.binary = isBinary;
var columnCount = this.parseInt16();
msg.columnTypes = [];
for(var i = 0; i<columnCount; i++) {
msg.columnTypes[i] = this.parseInt16();
msg.columnTypes.push(this.parseInt16());
}
return msg;
};
Connection.prototype.parseInt8 = function () {
var value = Number(this.buffer[this.offset]);
this.offset++;
return value;
};
Connection.prototype.readChar = function() {
return Buffer([this.buffer[this.offset++]]).toString(this.encoding);
};
Connection.prototype.parseInt32 = function() {
var value = this.peekInt32();
var value = this.buffer.readInt32BE(this.offset, true);
this.offset += 4;
return value;
};
Connection.prototype.peekInt32 = function(offset) {
offset = offset || this.offset;
var buffer = this.buffer;
return ((buffer[offset++] << 24) +
(buffer[offset++] << 16) +
(buffer[offset++] << 8) +
buffer[offset++]);
};
Connection.prototype.parseInt16 = function() {
return ((this.buffer[this.offset++] << 8) +
(this.buffer[this.offset++] << 0));
var value = this.buffer.readInt16BE(this.offset, true);
this.offset += 2;
return value;
};
Connection.prototype.readString = function(length) {
return this.buffer.toString(this.encoding, this.offset,
(this.offset += length));
return this.buffer.toString(this.encoding, this.offset, (this.offset += length));
};
Connection.prototype.readBytes = function(length) {

Loading…
Cancel
Save