You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
Improve benchmark by using a higher precision and fix js parser benchmark for buffers
This commit is contained in:
@@ -25,10 +25,8 @@ var num_clients = returnArg('clients', 1);
|
|||||||
var run_time = returnArg('time', 2500); // ms
|
var run_time = returnArg('time', 2500); // ms
|
||||||
var versions_logged = false;
|
var versions_logged = false;
|
||||||
var client_options = {
|
var client_options = {
|
||||||
return_buffers: false,
|
|
||||||
max_attempts: 4,
|
|
||||||
parser: returnArg('parser', 'hiredis')
|
parser: returnArg('parser', 'hiredis')
|
||||||
};
|
};
|
||||||
var small_str, large_str, small_buf, large_buf, very_large_str, very_large_buf;
|
var small_str, large_str, small_buf, large_buf, very_large_str, very_large_buf;
|
||||||
|
|
||||||
function lpad(input, len, chr) {
|
function lpad(input, len, chr) {
|
||||||
@@ -42,7 +40,7 @@ function lpad(input, len, chr) {
|
|||||||
|
|
||||||
metrics.Histogram.prototype.print_line = function () {
|
metrics.Histogram.prototype.print_line = function () {
|
||||||
var obj = this.printObj();
|
var obj = this.printObj();
|
||||||
return lpad(obj.min, 4) + '/' + lpad(obj.max, 4) + '/' + lpad(obj.mean.toFixed(2), 7);
|
return lpad((obj.min / 1000000).toFixed(2), 6) + '/' + lpad((obj.max / 1000000).toFixed(2), 6) + '/' + lpad((obj.mean / 1000000).toFixed(2), 6);
|
||||||
};
|
};
|
||||||
|
|
||||||
function Test(args) {
|
function Test(args) {
|
||||||
@@ -54,7 +52,8 @@ function Test(args) {
|
|||||||
this.commands_completed = 0;
|
this.commands_completed = 0;
|
||||||
this.max_pipeline = this.args.pipeline || 50;
|
this.max_pipeline = this.args.pipeline || 50;
|
||||||
this.batch_pipeline = this.args.batch || 0;
|
this.batch_pipeline = this.args.batch || 0;
|
||||||
this.client_options = args.client_options || client_options;
|
this.client_options = args.client_options || {};
|
||||||
|
this.client_options.parser = client_options.parser;
|
||||||
this.connect_latency = new metrics.Histogram();
|
this.connect_latency = new metrics.Histogram();
|
||||||
this.ready_latency = new metrics.Histogram();
|
this.ready_latency = new metrics.Histogram();
|
||||||
this.command_latency = new metrics.Histogram();
|
this.command_latency = new metrics.Histogram();
|
||||||
@@ -131,14 +130,6 @@ Test.prototype.fill_pipeline = function () {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.clients[0].should_buffer) {
|
|
||||||
var self = this;
|
|
||||||
setTimeout(function() {
|
|
||||||
self.fill_pipeline();
|
|
||||||
}, 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.batch_pipeline) {
|
if (this.batch_pipeline) {
|
||||||
this.batch();
|
this.batch();
|
||||||
} else {
|
} else {
|
||||||
@@ -153,7 +144,7 @@ Test.prototype.fill_pipeline = function () {
|
|||||||
Test.prototype.batch = function () {
|
Test.prototype.batch = function () {
|
||||||
var self = this,
|
var self = this,
|
||||||
cur_client = client_nr++ % this.clients.length,
|
cur_client = client_nr++ % this.clients.length,
|
||||||
start = Date.now(),
|
start = process.hrtime(),
|
||||||
i = 0,
|
i = 0,
|
||||||
batch = this.clients[cur_client].batch();
|
batch = this.clients[cur_client].batch();
|
||||||
|
|
||||||
@@ -167,7 +158,7 @@ Test.prototype.batch = function () {
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
self.commands_completed += res.length;
|
self.commands_completed += res.length;
|
||||||
self.command_latency.update(Date.now() - start);
|
self.command_latency.update(process.hrtime(start)[1]);
|
||||||
self.fill_pipeline();
|
self.fill_pipeline();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -189,14 +180,14 @@ Test.prototype.stop_clients = function () {
|
|||||||
Test.prototype.send_next = function () {
|
Test.prototype.send_next = function () {
|
||||||
var self = this,
|
var self = this,
|
||||||
cur_client = this.commands_sent % this.clients.length,
|
cur_client = this.commands_sent % this.clients.length,
|
||||||
start = Date.now();
|
start = process.hrtime();
|
||||||
|
|
||||||
this.clients[cur_client][this.args.command](this.args.args, function (err, res) {
|
this.clients[cur_client][this.args.command](this.args.args, function (err, res) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
self.commands_completed++;
|
self.commands_completed++;
|
||||||
self.command_latency.update(Date.now() - start);
|
self.command_latency.update(process.hrtime(start)[1]);
|
||||||
self.fill_pipeline();
|
self.fill_pipeline();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user