11'use strict' ;
22
33var path = require ( 'path' ) ;
4- var RedisProcess = require ( " ../test/lib/redis-process" ) ;
4+ var RedisProcess = require ( ' ../test/lib/redis-process' ) ;
55var rp ;
6- var redis = require ( " ../index" ) ;
6+ var redis = require ( ' ../index' ) ;
77var totalTime = 0 ;
8- var metrics = require ( " metrics" ) ;
8+ var metrics = require ( ' metrics' ) ;
99var num_clients = parseInt ( process . argv [ 2 ] , 10 ) || 5 ;
1010var num_requests = 50000 ;
1111var tests = [ ] ;
@@ -19,7 +19,7 @@ var small_str, large_str, small_buf, large_buf, very_large_str, very_large_buf;
1919
2020function lpad ( input , len , chr ) {
2121 var str = input . toString ( ) ;
22- chr = chr || " " ;
22+ chr = chr || ' ' ;
2323
2424 while ( str . length < len ) {
2525 str = chr + str ;
@@ -30,7 +30,7 @@ function lpad(input, len, chr) {
3030metrics . Histogram . prototype . print_line = function ( ) {
3131 var obj = this . printObj ( ) ;
3232
33- return lpad ( obj . min , 4 ) + "/" + lpad ( obj . max , 4 ) + "/" + lpad ( obj . mean . toFixed ( 2 ) , 7 ) + "/" + lpad ( obj . p95 . toFixed ( 2 ) , 7 ) ;
33+ return lpad ( obj . min , 4 ) + '/' + lpad ( obj . max , 4 ) + '/' + lpad ( obj . mean . toFixed ( 2 ) , 7 ) + '/' + lpad ( obj . p95 . toFixed ( 2 ) , 7 ) ;
3434} ;
3535
3636function Test ( args ) {
@@ -66,14 +66,14 @@ Test.prototype.new_client = function (id) {
6666 new_client = redis . createClient ( this . client_options ) ;
6767 new_client . create_time = Date . now ( ) ;
6868
69- new_client . on ( " connect" , function ( ) {
69+ new_client . on ( ' connect' , function ( ) {
7070 self . connect_latency . update ( Date . now ( ) - new_client . create_time ) ;
7171 } ) ;
7272
73- new_client . on ( " ready" , function ( ) {
73+ new_client . on ( ' ready' , function ( ) {
7474 if ( ! versions_logged ) {
75- console . log ( " Client count: " + num_clients + " , node version: " + process . versions . node + " , server version: " +
76- new_client . server_info . redis_version + " , parser: " + new_client . reply_parser . name ) ;
75+ console . log ( ' Client count: ' + num_clients + ' , node version: ' + process . versions . node + ' , server version: ' +
76+ new_client . server_info . redis_version + ' , parser: ' + new_client . reply_parser . name ) ;
7777 versions_logged = true ;
7878 }
7979 self . ready_latency . update ( Date . now ( ) - new_client . create_time ) ;
@@ -84,7 +84,7 @@ Test.prototype.new_client = function (id) {
8484 } ) ;
8585
8686 // If no redis server is running, start one
87- new_client . on ( " error" , function ( err ) {
87+ new_client . on ( ' error' , function ( err ) {
8888 if ( err . code === 'CONNECTION_BROKEN' ) {
8989 throw err ;
9090 }
@@ -105,7 +105,7 @@ Test.prototype.new_client = function (id) {
105105} ;
106106
107107Test . prototype . on_clients_ready = function ( ) {
108- process . stdout . write ( lpad ( this . args . descr , 13 ) + ", " + lpad ( this . args . pipeline , 5 ) + "/" + this . clients_ready + " " ) ;
108+ process . stdout . write ( lpad ( this . args . descr , 13 ) + ', ' + lpad ( this . args . pipeline , 5 ) + '/' + this . clients_ready + ' ' ) ;
109109 this . test_start = Date . now ( ) ;
110110
111111 this . fill_pipeline ( ) ;
@@ -159,64 +159,64 @@ Test.prototype.print_stats = function () {
159159 var duration = Date . now ( ) - this . test_start ;
160160 totalTime += duration ;
161161
162- console . log ( " min/max/avg/p95: " + this . command_latency . print_line ( ) + " " + lpad ( duration , 6 ) + " ms total, " +
163- lpad ( ( this . num_requests / ( duration / 1000 ) ) . toFixed ( 2 ) , 8 ) + " ops/sec" ) ;
162+ console . log ( ' min/max/avg/p95: ' + this . command_latency . print_line ( ) + ' ' + lpad ( duration , 6 ) + ' ms total, ' +
163+ lpad ( ( this . num_requests / ( duration / 1000 ) ) . toFixed ( 2 ) , 8 ) + ' ops/sec' ) ;
164164} ;
165165
166- small_str = " 1234" ;
166+ small_str = ' 1234' ;
167167small_buf = new Buffer ( small_str ) ;
168- large_str = ( new Array ( 4096 + 1 ) . join ( "-" ) ) ;
168+ large_str = ( new Array ( 4096 + 1 ) . join ( '-' ) ) ;
169169large_buf = new Buffer ( large_str ) ;
170- very_large_str = ( new Array ( ( 4 * 1024 * 1024 ) + 1 ) . join ( "-" ) ) ;
170+ very_large_str = ( new Array ( ( 4 * 1024 * 1024 ) + 1 ) . join ( '-' ) ) ;
171171very_large_buf = new Buffer ( very_large_str ) ;
172172
173- tests . push ( new Test ( { descr : " PING" , command : " ping" , args : [ ] , pipeline : 1 } ) ) ;
174- tests . push ( new Test ( { descr : " PING" , command : " ping" , args : [ ] , pipeline : 50 } ) ) ;
173+ tests . push ( new Test ( { descr : ' PING' , command : ' ping' , args : [ ] , pipeline : 1 } ) ) ;
174+ tests . push ( new Test ( { descr : ' PING' , command : ' ping' , args : [ ] , pipeline : 50 } ) ) ;
175175
176- tests . push ( new Test ( { descr : " SET 4B str" , command : " set" , args : [ " foo_rand000000000000" , small_str ] , pipeline : 1 } ) ) ;
177- tests . push ( new Test ( { descr : " SET 4B str" , command : " set" , args : [ " foo_rand000000000000" , small_str ] , pipeline : 50 } ) ) ;
176+ tests . push ( new Test ( { descr : ' SET 4B str' , command : ' set' , args : [ ' foo_rand000000000000' , small_str ] , pipeline : 1 } ) ) ;
177+ tests . push ( new Test ( { descr : ' SET 4B str' , command : ' set' , args : [ ' foo_rand000000000000' , small_str ] , pipeline : 50 } ) ) ;
178178
179- tests . push ( new Test ( { descr : " SET 4B buf" , command : " set" , args : [ " foo_rand000000000000" , small_buf ] , pipeline : 1 } ) ) ;
180- tests . push ( new Test ( { descr : " SET 4B buf" , command : " set" , args : [ " foo_rand000000000000" , small_buf ] , pipeline : 50 } ) ) ;
179+ tests . push ( new Test ( { descr : ' SET 4B buf' , command : ' set' , args : [ ' foo_rand000000000000' , small_buf ] , pipeline : 1 } ) ) ;
180+ tests . push ( new Test ( { descr : ' SET 4B buf' , command : ' set' , args : [ ' foo_rand000000000000' , small_buf ] , pipeline : 50 } ) ) ;
181181
182- tests . push ( new Test ( { descr : " GET 4B str" , command : " get" , args : [ " foo_rand000000000000" ] , pipeline : 1 } ) ) ;
183- tests . push ( new Test ( { descr : " GET 4B str" , command : " get" , args : [ " foo_rand000000000000" ] , pipeline : 50 } ) ) ;
182+ tests . push ( new Test ( { descr : ' GET 4B str' , command : ' get' , args : [ ' foo_rand000000000000' ] , pipeline : 1 } ) ) ;
183+ tests . push ( new Test ( { descr : ' GET 4B str' , command : ' get' , args : [ ' foo_rand000000000000' ] , pipeline : 50 } ) ) ;
184184
185- tests . push ( new Test ( { descr : " GET 4B buf" , command : " get" , args : [ " foo_rand000000000000" ] , pipeline : 1 , client_opts : { return_buffers : true } } ) ) ;
186- tests . push ( new Test ( { descr : " GET 4B buf" , command : " get" , args : [ " foo_rand000000000000" ] , pipeline : 50 , client_opts : { return_buffers : true } } ) ) ;
185+ tests . push ( new Test ( { descr : ' GET 4B buf' , command : ' get' , args : [ ' foo_rand000000000000' ] , pipeline : 1 , client_opts : { return_buffers : true } } ) ) ;
186+ tests . push ( new Test ( { descr : ' GET 4B buf' , command : ' get' , args : [ ' foo_rand000000000000' ] , pipeline : 50 , client_opts : { return_buffers : true } } ) ) ;
187187
188- tests . push ( new Test ( { descr : " SET 4KiB str" , command : " set" , args : [ " foo_rand000000000001" , large_str ] , pipeline : 1 } ) ) ;
189- tests . push ( new Test ( { descr : " SET 4KiB str" , command : " set" , args : [ " foo_rand000000000001" , large_str ] , pipeline : 50 } ) ) ;
188+ tests . push ( new Test ( { descr : ' SET 4KiB str' , command : ' set' , args : [ ' foo_rand000000000001' , large_str ] , pipeline : 1 } ) ) ;
189+ tests . push ( new Test ( { descr : ' SET 4KiB str' , command : ' set' , args : [ ' foo_rand000000000001' , large_str ] , pipeline : 50 } ) ) ;
190190
191- tests . push ( new Test ( { descr : " SET 4KiB buf" , command : " set" , args : [ " foo_rand000000000001" , large_buf ] , pipeline : 1 } ) ) ;
192- tests . push ( new Test ( { descr : " SET 4KiB buf" , command : " set" , args : [ " foo_rand000000000001" , large_buf ] , pipeline : 50 } ) ) ;
191+ tests . push ( new Test ( { descr : ' SET 4KiB buf' , command : ' set' , args : [ ' foo_rand000000000001' , large_buf ] , pipeline : 1 } ) ) ;
192+ tests . push ( new Test ( { descr : ' SET 4KiB buf' , command : ' set' , args : [ ' foo_rand000000000001' , large_buf ] , pipeline : 50 } ) ) ;
193193
194- tests . push ( new Test ( { descr : " GET 4KiB str" , command : " get" , args : [ " foo_rand000000000001" ] , pipeline : 1 } ) ) ;
195- tests . push ( new Test ( { descr : " GET 4KiB str" , command : " get" , args : [ " foo_rand000000000001" ] , pipeline : 50 } ) ) ;
194+ tests . push ( new Test ( { descr : ' GET 4KiB str' , command : ' get' , args : [ ' foo_rand000000000001' ] , pipeline : 1 } ) ) ;
195+ tests . push ( new Test ( { descr : ' GET 4KiB str' , command : ' get' , args : [ ' foo_rand000000000001' ] , pipeline : 50 } ) ) ;
196196
197- tests . push ( new Test ( { descr : " GET 4KiB buf" , command : " get" , args : [ " foo_rand000000000001" ] , pipeline : 1 , client_opts : { return_buffers : true } } ) ) ;
198- tests . push ( new Test ( { descr : " GET 4KiB buf" , command : " get" , args : [ " foo_rand000000000001" ] , pipeline : 50 , client_opts : { return_buffers : true } } ) ) ;
197+ tests . push ( new Test ( { descr : ' GET 4KiB buf' , command : ' get' , args : [ ' foo_rand000000000001' ] , pipeline : 1 , client_opts : { return_buffers : true } } ) ) ;
198+ tests . push ( new Test ( { descr : ' GET 4KiB buf' , command : ' get' , args : [ ' foo_rand000000000001' ] , pipeline : 50 , client_opts : { return_buffers : true } } ) ) ;
199199
200- tests . push ( new Test ( { descr : " INCR" , command : " incr" , args : [ " counter_rand000000000000" ] , pipeline : 1 } ) ) ;
201- tests . push ( new Test ( { descr : " INCR" , command : " incr" , args : [ " counter_rand000000000000" ] , pipeline : 50 } ) ) ;
200+ tests . push ( new Test ( { descr : ' INCR' , command : ' incr' , args : [ ' counter_rand000000000000' ] , pipeline : 1 } ) ) ;
201+ tests . push ( new Test ( { descr : ' INCR' , command : ' incr' , args : [ ' counter_rand000000000000' ] , pipeline : 50 } ) ) ;
202202
203- tests . push ( new Test ( { descr : " LPUSH" , command : " lpush" , args : [ " mylist" , small_str ] , pipeline : 1 } ) ) ;
204- tests . push ( new Test ( { descr : " LPUSH" , command : " lpush" , args : [ " mylist" , small_str ] , pipeline : 50 } ) ) ;
203+ tests . push ( new Test ( { descr : ' LPUSH' , command : ' lpush' , args : [ ' mylist' , small_str ] , pipeline : 1 } ) ) ;
204+ tests . push ( new Test ( { descr : ' LPUSH' , command : ' lpush' , args : [ ' mylist' , small_str ] , pipeline : 50 } ) ) ;
205205
206- tests . push ( new Test ( { descr : " LRANGE 10" , command : " lrange" , args : [ " mylist" , "0" , "9" ] , pipeline : 1 } ) ) ;
207- tests . push ( new Test ( { descr : " LRANGE 10" , command : " lrange" , args : [ " mylist" , "0" , "9" ] , pipeline : 50 } ) ) ;
206+ tests . push ( new Test ( { descr : ' LRANGE 10' , command : ' lrange' , args : [ ' mylist' , '0' , '9' ] , pipeline : 1 } ) ) ;
207+ tests . push ( new Test ( { descr : ' LRANGE 10' , command : ' lrange' , args : [ ' mylist' , '0' , '9' ] , pipeline : 50 } ) ) ;
208208
209- tests . push ( new Test ( { descr : " LRANGE 100" , command : " lrange" , args : [ " mylist" , "0" , "99" ] , pipeline : 1 } ) ) ;
210- tests . push ( new Test ( { descr : " LRANGE 100" , command : " lrange" , args : [ " mylist" , "0" , "99" ] , pipeline : 50 } ) ) ;
209+ tests . push ( new Test ( { descr : ' LRANGE 100' , command : ' lrange' , args : [ ' mylist' , '0' , '99' ] , pipeline : 1 } ) ) ;
210+ tests . push ( new Test ( { descr : ' LRANGE 100' , command : ' lrange' , args : [ ' mylist' , '0' , '99' ] , pipeline : 50 } ) ) ;
211211
212- tests . push ( new Test ( { descr : " SET 4MiB buf" , command : " set" , args : [ " foo_rand000000000002" , very_large_buf ] , pipeline : 1 , reqs : 500 } ) ) ;
213- tests . push ( new Test ( { descr : " SET 4MiB buf" , command : " set" , args : [ " foo_rand000000000002" , very_large_buf ] , pipeline : 50 , reqs : 500 } ) ) ;
212+ tests . push ( new Test ( { descr : ' SET 4MiB buf' , command : ' set' , args : [ ' foo_rand000000000002' , very_large_buf ] , pipeline : 1 , reqs : 500 } ) ) ;
213+ tests . push ( new Test ( { descr : ' SET 4MiB buf' , command : ' set' , args : [ ' foo_rand000000000002' , very_large_buf ] , pipeline : 50 , reqs : 500 } ) ) ;
214214
215- tests . push ( new Test ( { descr : " GET 4MiB str" , command : " get" , args : [ " foo_rand000000000002" ] , pipeline : 1 , reqs : 100 } ) ) ;
216- tests . push ( new Test ( { descr : " GET 4MiB str" , command : " get" , args : [ " foo_rand000000000002" ] , pipeline : 50 , reqs : 100 } ) ) ;
215+ tests . push ( new Test ( { descr : ' GET 4MiB str' , command : ' get' , args : [ ' foo_rand000000000002' ] , pipeline : 1 , reqs : 100 } ) ) ;
216+ tests . push ( new Test ( { descr : ' GET 4MiB str' , command : ' get' , args : [ ' foo_rand000000000002' ] , pipeline : 50 , reqs : 100 } ) ) ;
217217
218- tests . push ( new Test ( { descr : " GET 4MiB buf" , command : " get" , args : [ " foo_rand000000000002" ] , pipeline : 1 , reqs : 100 , client_opts : { return_buffers : true } } ) ) ;
219- tests . push ( new Test ( { descr : " GET 4MiB buf" , command : " get" , args : [ " foo_rand000000000002" ] , pipeline : 50 , reqs : 100 , client_opts : { return_buffers : true } } ) ) ;
218+ tests . push ( new Test ( { descr : ' GET 4MiB buf' , command : ' get' , args : [ ' foo_rand000000000002' ] , pipeline : 1 , reqs : 100 , client_opts : { return_buffers : true } } ) ) ;
219+ tests . push ( new Test ( { descr : ' GET 4MiB buf' , command : ' get' , args : [ ' foo_rand000000000002' ] , pipeline : 50 , reqs : 100 , client_opts : { return_buffers : true } } ) ) ;
220220
221221function next ( ) {
222222 var test = tests . shift ( ) ;
@@ -231,7 +231,7 @@ function next() {
231231 next ( ) ;
232232 } ) ;
233233 } else {
234- console . log ( " End of tests. Total time elapsed:" , totalTime , 'ms' ) ;
234+ console . log ( ' End of tests. Total time elapsed:' , totalTime , 'ms' ) ;
235235 process . exit ( 0 ) ;
236236 }
237237}
0 commit comments