Skip to content

Commit f2ca678

Browse files
author
Ruben Bridgewater
committed
Update benchmark to also signal tcp / socket connections
1 parent 92be1e9 commit f2ca678

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

benchmarks/multi_bench.js

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ var num_clients = returnArg('clients', 1);
2525
var run_time = returnArg('time', 2500); // ms
2626
var versions_logged = false;
2727
var client_options = {
28-
parser: returnArg('parser', 'hiredis')
28+
parser: returnArg('parser', 'hiredis'),
29+
path: returnArg('socket') // '/tmp/redis.sock'
2930
};
3031
var small_str, large_str, small_buf, large_buf, very_large_str, very_large_buf;
3132

@@ -40,7 +41,7 @@ function lpad(input, len, chr) {
4041

4142
metrics.Histogram.prototype.print_line = function () {
4243
var obj = this.printObj();
43-
return lpad((obj.min / 1000000).toFixed(2), 6) + '/' + lpad((obj.max / 1000000).toFixed(2), 6) + '/' + lpad((obj.mean / 1000000).toFixed(2), 6);
44+
return lpad((obj.min / 1e6).toFixed(2), 6) + '/' + lpad((obj.max / 1e6).toFixed(2), 6) + '/' + lpad((obj.mean / 1e6).toFixed(2), 6);
4445
};
4546

4647
function Test(args) {
@@ -54,6 +55,10 @@ function Test(args) {
5455
this.batch_pipeline = this.args.batch || 0;
5556
this.client_options = args.client_options || {};
5657
this.client_options.parser = client_options.parser;
58+
this.client_options.connect_timeout = 1000;
59+
if (client_options.path) {
60+
this.client_options.path = client_options.path;
61+
}
5762
this.connect_latency = new metrics.Histogram();
5863
this.ready_latency = new metrics.Histogram();
5964
this.command_latency = new metrics.Histogram();
@@ -78,9 +83,14 @@ Test.prototype.new_client = function (id) {
7883
});
7984

8085
new_client.on('ready', function () {
81-
if (! versions_logged) {
82-
console.log('Client count: ' + num_clients + ', node version: ' + process.versions.node + ', server version: ' +
83-
new_client.server_info.redis_version + ', parser: ' + new_client.reply_parser.name);
86+
if (!versions_logged) {
87+
console.log(
88+
'clients: ' + num_clients +
89+
', NodeJS: ' + process.versions.node +
90+
', Redis: ' + new_client.server_info.redis_version +
91+
', parser: ' + client_options.parser +
92+
', connected by: ' + (client_options.path ? 'socket' : 'tcp')
93+
);
8494
versions_logged = true;
8595
}
8696
self.ready_latency.update(Date.now() - new_client.create_time);
@@ -197,7 +207,7 @@ Test.prototype.print_stats = function () {
197207
totalTime += duration;
198208

199209
console.log('min/max/avg: ' + this.command_latency.print_line() + ' ' + lpad(duration, 6) + 'ms total, ' +
200-
lpad((this.commands_completed / (duration / 1000)).toFixed(2), 9) + ' ops/sec');
210+
lpad(Math.round(this.commands_completed / (duration / 1000)), 7) + ' ops/sec');
201211
};
202212

203213
small_str = '1234';
@@ -208,71 +218,54 @@ very_large_str = (new Array((4 * 1024 * 1024) + 1).join('-'));
208218
very_large_buf = new Buffer(very_large_str);
209219

210220
tests.push(new Test({descr: 'PING', command: 'ping', args: [], pipeline: 1}));
211-
// tests.push(new Test({descr: 'PING', command: 'ping', args: [], pipeline: 50}));
212221
tests.push(new Test({descr: 'PING', command: 'ping', args: [], batch: 50}));
213222

214223
tests.push(new Test({descr: 'SET 4B str', command: 'set', args: ['foo_rand000000000000', small_str], pipeline: 1}));
215-
// tests.push(new Test({descr: 'SET 4B str', command: 'set', args: ['foo_rand000000000000', small_str], pipeline: 50}));
216224
tests.push(new Test({descr: 'SET 4B str', command: 'set', args: ['foo_rand000000000000', small_str], batch: 50}));
217225

218226
tests.push(new Test({descr: 'SET 4B buf', command: 'set', args: ['foo_rand000000000000', small_buf], pipeline: 1}));
219-
// tests.push(new Test({descr: 'SET 4B buf', command: 'set', args: ['foo_rand000000000000', small_buf], pipeline: 50}));
220227
tests.push(new Test({descr: 'SET 4B buf', command: 'set', args: ['foo_rand000000000000', small_buf], batch: 50}));
221228

222229
tests.push(new Test({descr: 'GET 4B str', command: 'get', args: ['foo_rand000000000000'], pipeline: 1}));
223-
// tests.push(new Test({descr: 'GET 4B str', command: 'get', args: ['foo_rand000000000000'], pipeline: 50}));
224230
tests.push(new Test({descr: 'GET 4B str', command: 'get', args: ['foo_rand000000000000'], batch: 50}));
225231

226232
tests.push(new Test({descr: 'GET 4B buf', command: 'get', args: ['foo_rand000000000000'], pipeline: 1, client_opts: { return_buffers: true} }));
227-
// tests.push(new Test({descr: 'GET 4B buf', command: 'get', args: ['foo_rand000000000000'], pipeline: 50, client_opts: { return_buffers: true} }));
228233
tests.push(new Test({descr: 'GET 4B buf', command: 'get', args: ['foo_rand000000000000'], batch: 50, client_opts: { return_buffers: true} }));
229234

230235
tests.push(new Test({descr: 'SET 4KiB str', command: 'set', args: ['foo_rand000000000001', large_str], pipeline: 1}));
231-
// tests.push(new Test({descr: 'SET 4KiB str', command: 'set', args: ['foo_rand000000000001', large_str], pipeline: 50}));
232236
tests.push(new Test({descr: 'SET 4KiB str', command: 'set', args: ['foo_rand000000000001', large_str], batch: 50}));
233237

234238
tests.push(new Test({descr: 'SET 4KiB buf', command: 'set', args: ['foo_rand000000000001', large_buf], pipeline: 1}));
235-
// tests.push(new Test({descr: 'SET 4KiB buf', command: 'set', args: ['foo_rand000000000001', large_buf], pipeline: 50}));
236239
tests.push(new Test({descr: 'SET 4KiB buf', command: 'set', args: ['foo_rand000000000001', large_buf], batch: 50}));
237240

238241
tests.push(new Test({descr: 'GET 4KiB str', command: 'get', args: ['foo_rand000000000001'], pipeline: 1}));
239-
// tests.push(new Test({descr: 'GET 4KiB str', command: 'get', args: ['foo_rand000000000001'], pipeline: 50}));
240242
tests.push(new Test({descr: 'GET 4KiB str', command: 'get', args: ['foo_rand000000000001'], batch: 50}));
241243

242244
tests.push(new Test({descr: 'GET 4KiB buf', command: 'get', args: ['foo_rand000000000001'], pipeline: 1, client_opts: { return_buffers: true} }));
243-
// tests.push(new Test({descr: 'GET 4KiB buf', command: 'get', args: ['foo_rand000000000001'], pipeline: 50, client_opts: { return_buffers: true} }));
244245
tests.push(new Test({descr: 'GET 4KiB buf', command: 'get', args: ['foo_rand000000000001'], batch: 50, client_opts: { return_buffers: true} }));
245246

246247
tests.push(new Test({descr: 'INCR', command: 'incr', args: ['counter_rand000000000000'], pipeline: 1}));
247-
// tests.push(new Test({descr: 'INCR', command: 'incr', args: ['counter_rand000000000000'], pipeline: 50}));
248248
tests.push(new Test({descr: 'INCR', command: 'incr', args: ['counter_rand000000000000'], batch: 50}));
249249

250250
tests.push(new Test({descr: 'LPUSH', command: 'lpush', args: ['mylist', small_str], pipeline: 1}));
251-
// tests.push(new Test({descr: 'LPUSH', command: 'lpush', args: ['mylist', small_str], pipeline: 50}));
252251
tests.push(new Test({descr: 'LPUSH', command: 'lpush', args: ['mylist', small_str], batch: 50}));
253252

254253
tests.push(new Test({descr: 'LRANGE 10', command: 'lrange', args: ['mylist', '0', '9'], pipeline: 1}));
255-
// tests.push(new Test({descr: 'LRANGE 10', command: 'lrange', args: ['mylist', '0', '9'], pipeline: 50}));
256254
tests.push(new Test({descr: 'LRANGE 10', command: 'lrange', args: ['mylist', '0', '9'], batch: 50}));
257255

258256
tests.push(new Test({descr: 'LRANGE 100', command: 'lrange', args: ['mylist', '0', '99'], pipeline: 1}));
259-
// tests.push(new Test({descr: 'LRANGE 100', command: 'lrange', args: ['mylist', '0', '99'], pipeline: 50}));
260257
tests.push(new Test({descr: 'LRANGE 100', command: 'lrange', args: ['mylist', '0', '99'], batch: 50}));
261258

262259
tests.push(new Test({descr: 'SET 4MiB str', command: 'set', args: ['foo_rand000000000002', very_large_str], pipeline: 1}));
263-
// tests.push(new Test({descr: 'SET 4MiB str', command: 'set', args: ['foo_rand000000000002', very_large_str], pipeline: 20}));
264260
tests.push(new Test({descr: 'SET 4MiB str', command: 'set', args: ['foo_rand000000000002', very_large_str], batch: 20}));
265261

266262
tests.push(new Test({descr: 'SET 4MiB buf', command: 'set', args: ['foo_rand000000000002', very_large_buf], pipeline: 1}));
267-
// tests.push(new Test({descr: 'SET 4MiB buf', command: 'set', args: ['foo_rand000000000002', very_large_buf], pipeline: 20}));
268263
tests.push(new Test({descr: 'SET 4MiB buf', command: 'set', args: ['foo_rand000000000002', very_large_buf], batch: 20}));
269264

270265
tests.push(new Test({descr: 'GET 4MiB str', command: 'get', args: ['foo_rand000000000002'], pipeline: 1}));
271-
// tests.push(new Test({descr: 'GET 4MiB str', command: 'get', args: ['foo_rand000000000002'], pipeline: 20}));
272266
tests.push(new Test({descr: 'GET 4MiB str', command: 'get', args: ['foo_rand000000000002'], batch: 20}));
273267

274268
tests.push(new Test({descr: 'GET 4MiB buf', command: 'get', args: ['foo_rand000000000002'], pipeline: 1, client_opts: { return_buffers: true} }));
275-
// tests.push(new Test({descr: 'GET 4MiB buf', command: 'get', args: ['foo_rand000000000002'], pipeline: 20, client_opts: { return_buffers: true} }));
276269
tests.push(new Test({descr: 'GET 4MiB buf', command: 'get', args: ['foo_rand000000000002'], batch: 20, client_opts: { return_buffers: true} }));
277270

278271
function next() {

0 commit comments

Comments
 (0)