@@ -25,7 +25,8 @@ var num_clients = returnArg('clients', 1);
2525var run_time = returnArg ( 'time' , 2500 ) ; // ms
2626var versions_logged = false ;
2727var client_options = {
28- parser : returnArg ( 'parser' , 'hiredis' )
28+ parser : returnArg ( 'parser' , 'hiredis' ) ,
29+ path : returnArg ( 'socket' ) // '/tmp/redis.sock'
2930} ;
3031var 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
4142metrics . 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
4647function 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
203213small_str = '1234' ;
@@ -208,71 +218,54 @@ very_large_str = (new Array((4 * 1024 * 1024) + 1).join('-'));
208218very_large_buf = new Buffer ( very_large_str ) ;
209219
210220tests . push ( new Test ( { descr : 'PING' , command : 'ping' , args : [ ] , pipeline : 1 } ) ) ;
211- // tests.push(new Test({descr: 'PING', command: 'ping', args: [], pipeline: 50}));
212221tests . push ( new Test ( { descr : 'PING' , command : 'ping' , args : [ ] , batch : 50 } ) ) ;
213222
214223tests . 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}));
216224tests . push ( new Test ( { descr : 'SET 4B str' , command : 'set' , args : [ 'foo_rand000000000000' , small_str ] , batch : 50 } ) ) ;
217225
218226tests . 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}));
220227tests . push ( new Test ( { descr : 'SET 4B buf' , command : 'set' , args : [ 'foo_rand000000000000' , small_buf ] , batch : 50 } ) ) ;
221228
222229tests . 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}));
224230tests . push ( new Test ( { descr : 'GET 4B str' , command : 'get' , args : [ 'foo_rand000000000000' ] , batch : 50 } ) ) ;
225231
226232tests . 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} }));
228233tests . push ( new Test ( { descr : 'GET 4B buf' , command : 'get' , args : [ 'foo_rand000000000000' ] , batch : 50 , client_opts : { return_buffers : true } } ) ) ;
229234
230235tests . 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}));
232236tests . push ( new Test ( { descr : 'SET 4KiB str' , command : 'set' , args : [ 'foo_rand000000000001' , large_str ] , batch : 50 } ) ) ;
233237
234238tests . 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}));
236239tests . push ( new Test ( { descr : 'SET 4KiB buf' , command : 'set' , args : [ 'foo_rand000000000001' , large_buf ] , batch : 50 } ) ) ;
237240
238241tests . 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}));
240242tests . push ( new Test ( { descr : 'GET 4KiB str' , command : 'get' , args : [ 'foo_rand000000000001' ] , batch : 50 } ) ) ;
241243
242244tests . 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} }));
244245tests . push ( new Test ( { descr : 'GET 4KiB buf' , command : 'get' , args : [ 'foo_rand000000000001' ] , batch : 50 , client_opts : { return_buffers : true } } ) ) ;
245246
246247tests . 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}));
248248tests . push ( new Test ( { descr : 'INCR' , command : 'incr' , args : [ 'counter_rand000000000000' ] , batch : 50 } ) ) ;
249249
250250tests . 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}));
252251tests . push ( new Test ( { descr : 'LPUSH' , command : 'lpush' , args : [ 'mylist' , small_str ] , batch : 50 } ) ) ;
253252
254253tests . 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}));
256254tests . push ( new Test ( { descr : 'LRANGE 10' , command : 'lrange' , args : [ 'mylist' , '0' , '9' ] , batch : 50 } ) ) ;
257255
258256tests . 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}));
260257tests . push ( new Test ( { descr : 'LRANGE 100' , command : 'lrange' , args : [ 'mylist' , '0' , '99' ] , batch : 50 } ) ) ;
261258
262259tests . 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}));
264260tests . push ( new Test ( { descr : 'SET 4MiB str' , command : 'set' , args : [ 'foo_rand000000000002' , very_large_str ] , batch : 20 } ) ) ;
265261
266262tests . 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}));
268263tests . push ( new Test ( { descr : 'SET 4MiB buf' , command : 'set' , args : [ 'foo_rand000000000002' , very_large_buf ] , batch : 20 } ) ) ;
269264
270265tests . 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}));
272266tests . push ( new Test ( { descr : 'GET 4MiB str' , command : 'get' , args : [ 'foo_rand000000000002' ] , batch : 20 } ) ) ;
273267
274268tests . 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} }));
276269tests . push ( new Test ( { descr : 'GET 4MiB buf' , command : 'get' , args : [ 'foo_rand000000000002' ] , batch : 20 , client_opts : { return_buffers : true } } ) ) ;
277270
278271function next ( ) {
0 commit comments