1
1
'use strict' ;
2
2
3
3
var path = require ( 'path' ) ;
4
- var RedisProcess = require ( " ../test/lib/redis-process" ) ;
4
+ var RedisProcess = require ( ' ../test/lib/redis-process' ) ;
5
5
var rp ;
6
- var redis = require ( " ../index" ) ;
6
+ var redis = require ( ' ../index' ) ;
7
7
var totalTime = 0 ;
8
- var metrics = require ( " metrics" ) ;
8
+ var metrics = require ( ' metrics' ) ;
9
9
var num_clients = parseInt ( process . argv [ 2 ] , 10 ) || 5 ;
10
10
var num_requests = 50000 ;
11
11
var tests = [ ] ;
@@ -19,7 +19,7 @@ var small_str, large_str, small_buf, large_buf, very_large_str, very_large_buf;
19
19
20
20
function lpad ( input , len , chr ) {
21
21
var str = input . toString ( ) ;
22
- chr = chr || " " ;
22
+ chr = chr || ' ' ;
23
23
24
24
while ( str . length < len ) {
25
25
str = chr + str ;
@@ -30,7 +30,7 @@ function lpad(input, len, chr) {
30
30
metrics . Histogram . prototype . print_line = function ( ) {
31
31
var obj = this . printObj ( ) ;
32
32
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 ) ;
34
34
} ;
35
35
36
36
function Test ( args ) {
@@ -66,14 +66,14 @@ Test.prototype.new_client = function (id) {
66
66
new_client = redis . createClient ( this . client_options ) ;
67
67
new_client . create_time = Date . now ( ) ;
68
68
69
- new_client . on ( " connect" , function ( ) {
69
+ new_client . on ( ' connect' , function ( ) {
70
70
self . connect_latency . update ( Date . now ( ) - new_client . create_time ) ;
71
71
} ) ;
72
72
73
- new_client . on ( " ready" , function ( ) {
73
+ new_client . on ( ' ready' , function ( ) {
74
74
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 ) ;
77
77
versions_logged = true ;
78
78
}
79
79
self . ready_latency . update ( Date . now ( ) - new_client . create_time ) ;
@@ -84,7 +84,7 @@ Test.prototype.new_client = function (id) {
84
84
} ) ;
85
85
86
86
// If no redis server is running, start one
87
- new_client . on ( " error" , function ( err ) {
87
+ new_client . on ( ' error' , function ( err ) {
88
88
if ( err . code === 'CONNECTION_BROKEN' ) {
89
89
throw err ;
90
90
}
@@ -105,7 +105,7 @@ Test.prototype.new_client = function (id) {
105
105
} ;
106
106
107
107
Test . 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 + ' ' ) ;
109
109
this . test_start = Date . now ( ) ;
110
110
111
111
this . fill_pipeline ( ) ;
@@ -159,64 +159,64 @@ Test.prototype.print_stats = function () {
159
159
var duration = Date . now ( ) - this . test_start ;
160
160
totalTime += duration ;
161
161
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' ) ;
164
164
} ;
165
165
166
- small_str = " 1234" ;
166
+ small_str = ' 1234' ;
167
167
small_buf = new Buffer ( small_str ) ;
168
- large_str = ( new Array ( 4096 + 1 ) . join ( "-" ) ) ;
168
+ large_str = ( new Array ( 4096 + 1 ) . join ( '-' ) ) ;
169
169
large_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 ( '-' ) ) ;
171
171
very_large_buf = new Buffer ( very_large_str ) ;
172
172
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 } ) ) ;
175
175
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 } ) ) ;
178
178
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 } ) ) ;
181
181
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 } ) ) ;
184
184
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 } } ) ) ;
187
187
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 } ) ) ;
190
190
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 } ) ) ;
193
193
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 } ) ) ;
196
196
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 } } ) ) ;
199
199
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 } ) ) ;
202
202
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 } ) ) ;
205
205
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 } ) ) ;
208
208
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 } ) ) ;
211
211
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 } ) ) ;
214
214
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 } ) ) ;
217
217
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 } } ) ) ;
220
220
221
221
function next ( ) {
222
222
var test = tests . shift ( ) ;
@@ -231,7 +231,7 @@ function next() {
231
231
next ( ) ;
232
232
} ) ;
233
233
} else {
234
- console . log ( " End of tests. Total time elapsed:" , totalTime , 'ms' ) ;
234
+ console . log ( ' End of tests. Total time elapsed:' , totalTime , 'ms' ) ;
235
235
process . exit ( 0 ) ;
236
236
}
237
237
}
0 commit comments