]> git.saurik.com Git - redis.git/blame - src/redis-benchmark.c
rioInitWithFile nad rioInitWithBuffer functions now take a rio structure pointer...
[redis.git] / src / redis-benchmark.c
CommitLineData
ed9b544e 1/* Redis benchmark utility.
2 *
12d090d2 3 * Copyright (c) 2009-2010, Salvatore Sanfilippo <antirez at gmail dot com>
ed9b544e 4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of Redis nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
5f5b9840 31#include "fmacros.h"
32
ed9b544e 33#include <stdio.h>
34#include <string.h>
35#include <stdlib.h>
36#include <unistd.h>
37#include <errno.h>
38#include <sys/time.h>
39#include <signal.h>
40#include <assert.h>
41
42#include "ae.h"
ec8f0667 43#include "hiredis.h"
ed9b544e 44#include "sds.h"
45#include "adlist.h"
46#include "zmalloc.h"
47
ed9b544e 48#define REDIS_NOTUSED(V) ((void) V)
49
50static struct config {
fc05e8c8
PN
51 aeEventLoop *el;
52 const char *hostip;
53 int hostport;
54 const char *hostsocket;
ed9b544e 55 int numclients;
ed9b544e 56 int liveclients;
bdbf3acf
PN
57 int requests;
58 int requests_issued;
59 int requests_finished;
ed9b544e 60 int keysize;
61 int datasize;
57172ffb 62 int randomkeys;
ecfaf6da 63 int randomkeys_keyspacelen;
ed9b544e 64 int keepalive;
65 long long start;
66 long long totlatency;
8146e316 67 long long *latency;
fc05e8c8 68 const char *title;
ed9b544e 69 list *clients;
70 int quiet;
71 int loop;
266373b2 72 int idlemode;
ed9b544e 73} config;
74
75typedef struct _client {
ec8f0667 76 redisContext *context;
ed9b544e 77 sds obuf;
3c49070b
PN
78 char *randptr[10]; /* needed for MSET against 10 keys */
79 size_t randlen;
8146e316 80 unsigned int written; /* bytes of 'obuf' already written */
8146e316
PN
81 long long start; /* start time of a request */
82 long long latency; /* request latency */
ed9b544e 83} *client;
84
85/* Prototypes */
86static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask);
87static void createMissingClients(client c);
88
89/* Implementation */
8146e316
PN
90static long long ustime(void) {
91 struct timeval tv;
92 long long ust;
93
94 gettimeofday(&tv, NULL);
95 ust = ((long)tv.tv_sec)*1000000;
96 ust += tv.tv_usec;
97 return ust;
98}
99
ed9b544e 100static long long mstime(void) {
101 struct timeval tv;
102 long long mst;
103
104 gettimeofday(&tv, NULL);
105 mst = ((long)tv.tv_sec)*1000;
106 mst += tv.tv_usec/1000;
107 return mst;
108}
109
110static void freeClient(client c) {
111 listNode *ln;
ec8f0667
PN
112 aeDeleteFileEvent(config.el,c->context->fd,AE_WRITABLE);
113 aeDeleteFileEvent(config.el,c->context->fd,AE_READABLE);
114 redisFree(c->context);
ed9b544e 115 sdsfree(c->obuf);
ed9b544e 116 zfree(c);
117 config.liveclients--;
118 ln = listSearchKey(config.clients,c);
119 assert(ln != NULL);
120 listDelNode(config.clients,ln);
121}
122
123static void freeAllClients(void) {
124 listNode *ln = config.clients->head, *next;
125
126 while(ln) {
127 next = ln->next;
128 freeClient(ln->value);
129 ln = next;
130 }
131}
132
133static void resetClient(client c) {
ec8f0667
PN
134 aeDeleteFileEvent(config.el,c->context->fd,AE_WRITABLE);
135 aeDeleteFileEvent(config.el,c->context->fd,AE_READABLE);
136 aeCreateFileEvent(config.el,c->context->fd,AE_WRITABLE,writeHandler,c);
ed9b544e 137 c->written = 0;
ed9b544e 138}
139
ecfaf6da 140static void randomizeClientKey(client c) {
ecfaf6da 141 char buf[32];
3c49070b 142 size_t i, r;
ecfaf6da 143
3c49070b
PN
144 for (i = 0; i < c->randlen; i++) {
145 r = random() % config.randomkeys_keyspacelen;
9b45592c 146 snprintf(buf,sizeof(buf),"%012zu",r);
3c49070b 147 memcpy(c->randptr[i],buf,12);
1cd3c1e0 148 }
ecfaf6da 149}
150
ed9b544e 151static void clientDone(client c) {
bdbf3acf 152 if (config.requests_finished == config.requests) {
ed9b544e 153 freeClient(c);
154 aeStop(config.el);
155 return;
156 }
157 if (config.keepalive) {
158 resetClient(c);
159 } else {
160 config.liveclients--;
161 createMissingClients(c);
162 config.liveclients++;
163 freeClient(c);
164 }
165}
166
ec8f0667 167static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
ed9b544e 168 client c = privdata;
ec8f0667 169 void *reply = NULL;
ed9b544e 170 REDIS_NOTUSED(el);
171 REDIS_NOTUSED(fd);
172 REDIS_NOTUSED(mask);
173
8146e316
PN
174 /* Calculate latency only for the first read event. This means that the
175 * server already sent the reply and we need to parse it. Parsing overhead
176 * is not part of the latency, so calculate it only once, here. */
177 if (c->latency < 0) c->latency = ustime()-(c->start);
178
ec8f0667
PN
179 if (redisBufferRead(c->context) != REDIS_OK) {
180 fprintf(stderr,"Error: %s\n",c->context->errstr);
181 exit(1);
182 } else {
183 if (redisGetReply(c->context,&reply) != REDIS_OK) {
184 fprintf(stderr,"Error: %s\n",c->context->errstr);
185 exit(1);
2fd30952 186 }
8146e316 187 if (reply != NULL) {
53f1d817
PN
188 if (reply == (void*)REDIS_REPLY_ERROR) {
189 fprintf(stderr,"Unexpected error reply, exiting...\n");
190 exit(1);
191 }
192
bdbf3acf
PN
193 if (config.requests_finished < config.requests)
194 config.latency[config.requests_finished++] = c->latency;
ec8f0667 195 clientDone(c);
8146e316 196 }
2fd30952 197 }
ed9b544e 198}
199
ec8f0667 200static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
ed9b544e 201 client c = privdata;
202 REDIS_NOTUSED(el);
203 REDIS_NOTUSED(fd);
204 REDIS_NOTUSED(mask);
205
bdbf3acf 206 /* Initialize request when nothing was written. */
23803889 207 if (c->written == 0) {
bdbf3acf
PN
208 /* Enforce upper bound to number of requests. */
209 if (config.requests_issued++ >= config.requests) {
210 freeClient(c);
211 return;
212 }
213
214 /* Really initialize: randomize keys and set start time. */
23803889 215 if (config.randomkeys) randomizeClientKey(c);
8146e316
PN
216 c->start = ustime();
217 c->latency = -1;
ed9b544e 218 }
23803889 219
ed9b544e 220 if (sdslen(c->obuf) > c->written) {
221 void *ptr = c->obuf+c->written;
ec8f0667 222 int nwritten = write(c->context->fd,ptr,sdslen(c->obuf)-c->written);
ed9b544e 223 if (nwritten == -1) {
61c47ecd 224 if (errno != EPIPE)
225 fprintf(stderr, "Writing to socket: %s\n", strerror(errno));
ed9b544e 226 freeClient(c);
227 return;
228 }
229 c->written += nwritten;
230 if (sdslen(c->obuf) == c->written) {
ec8f0667
PN
231 aeDeleteFileEvent(config.el,c->context->fd,AE_WRITABLE);
232 aeCreateFileEvent(config.el,c->context->fd,AE_READABLE,readHandler,c);
ed9b544e 233 }
234 }
235}
236
fc05e8c8 237static client createClient(const char *cmd, size_t len) {
ed9b544e 238 client c = zmalloc(sizeof(struct _client));
ec8f0667
PN
239 if (config.hostsocket == NULL) {
240 c->context = redisConnectNonBlock(config.hostip,config.hostport);
241 } else {
242 c->context = redisConnectUnixNonBlock(config.hostsocket);
ed9b544e 243 }
ec8f0667
PN
244 if (c->context->err) {
245 fprintf(stderr,"Could not connect to Redis at ");
246 if (config.hostsocket == NULL)
247 fprintf(stderr,"%s:%d: %s\n",config.hostip,config.hostport,c->context->errstr);
248 else
249 fprintf(stderr,"%s: %s\n",config.hostsocket,c->context->errstr);
250 exit(1);
251 }
3c49070b
PN
252 c->obuf = sdsnewlen(cmd,len);
253 c->randlen = 0;
ed9b544e 254 c->written = 0;
3c49070b
PN
255
256 /* Find substrings in the output buffer that need to be randomized. */
257 if (config.randomkeys) {
258 char *p = c->obuf, *newline;
259 while ((p = strstr(p,":rand:")) != NULL) {
260 newline = strstr(p,"\r\n");
261 assert(newline-(p+6) == 12); /* 12 chars for randomness */
262 assert(c->randlen < (signed)(sizeof(c->randptr)/sizeof(char*)));
263 c->randptr[c->randlen++] = p+6;
264 p = newline+2;
265 }
266 }
267
ec8f0667
PN
268 redisSetReplyObjectFunctions(c->context,NULL);
269 aeCreateFileEvent(config.el,c->context->fd,AE_WRITABLE,writeHandler,c);
ed9b544e 270 listAddNodeTail(config.clients,c);
ec8f0667 271 config.liveclients++;
ed9b544e 272 return c;
273}
274
275static void createMissingClients(client c) {
f474a5bd
DS
276 int n = 0;
277
ed9b544e 278 while(config.liveclients < config.numclients) {
23803889 279 createClient(c->obuf,sdslen(c->obuf));
f474a5bd
DS
280
281 /* Listen backlog is quite limited on most systems */
282 if (++n > 64) {
283 usleep(50000);
284 n = 0;
285 }
ed9b544e 286 }
287}
288
8146e316
PN
289static int compareLatency(const void *a, const void *b) {
290 return (*(long long*)a)-(*(long long*)b);
291}
292
ed0dd554 293static void showLatencyReport(void) {
8146e316 294 int i, curlat = 0;
ed9b544e 295 float perc, reqpersec;
296
bdbf3acf 297 reqpersec = (float)config.requests_finished/((float)config.totlatency/1000);
ed9b544e 298 if (!config.quiet) {
ed0dd554 299 printf("====== %s ======\n", config.title);
bdbf3acf 300 printf(" %d requests completed in %.2f seconds\n", config.requests_finished,
ed9b544e 301 (float)config.totlatency/1000);
302 printf(" %d parallel clients\n", config.numclients);
303 printf(" %d bytes payload\n", config.datasize);
304 printf(" keep alive: %d\n", config.keepalive);
305 printf("\n");
8146e316
PN
306
307 qsort(config.latency,config.requests,sizeof(long long),compareLatency);
308 for (i = 0; i < config.requests; i++) {
309 if (config.latency[i]/1000 != curlat || i == (config.requests-1)) {
310 curlat = config.latency[i]/1000;
311 perc = ((float)(i+1)*100)/config.requests;
312 printf("%.2f%% <= %d milliseconds\n", perc, curlat);
ed9b544e 313 }
314 }
315 printf("%.2f requests per second\n\n", reqpersec);
316 } else {
ed0dd554 317 printf("%s: %.2f requests per second\n", config.title, reqpersec);
ed9b544e 318 }
319}
320
fc05e8c8 321static void benchmark(const char *title, const char *cmd, int len) {
f2f2424e
PN
322 client c;
323
ed0dd554 324 config.title = title;
bdbf3acf
PN
325 config.requests_issued = 0;
326 config.requests_finished = 0;
ed9b544e 327
3c49070b 328 c = createClient(cmd,len);
f2f2424e
PN
329 createMissingClients(c);
330
331 config.start = mstime();
332 aeMain(config.el);
ed9b544e 333 config.totlatency = mstime()-config.start;
f2f2424e 334
ed0dd554 335 showLatencyReport();
ed9b544e 336 freeAllClients();
337}
338
39bf4402
PN
339/* Returns number of consumed options. */
340int parseOptions(int argc, const char **argv) {
ed9b544e 341 int i;
39bf4402
PN
342 int lastarg;
343 int exit_status = 1;
ed9b544e 344
345 for (i = 1; i < argc; i++) {
39bf4402
PN
346 lastarg = (i == (argc-1));
347
348 if (!strcmp(argv[i],"-c")) {
349 if (lastarg) goto invalid;
350 config.numclients = atoi(argv[++i]);
351 } else if (!strcmp(argv[i],"-n")) {
352 if (lastarg) goto invalid;
353 config.requests = atoi(argv[++i]);
354 } else if (!strcmp(argv[i],"-k")) {
355 if (lastarg) goto invalid;
356 config.keepalive = atoi(argv[++i]);
357 } else if (!strcmp(argv[i],"-h")) {
358 if (lastarg) goto invalid;
359 config.hostip = strdup(argv[++i]);
360 } else if (!strcmp(argv[i],"-p")) {
361 if (lastarg) goto invalid;
362 config.hostport = atoi(argv[++i]);
363 } else if (!strcmp(argv[i],"-s")) {
364 if (lastarg) goto invalid;
365 config.hostsocket = strdup(argv[++i]);
366 } else if (!strcmp(argv[i],"-d")) {
367 if (lastarg) goto invalid;
368 config.datasize = atoi(argv[++i]);
ed9b544e 369 if (config.datasize < 1) config.datasize=1;
370 if (config.datasize > 1024*1024) config.datasize = 1024*1024;
39bf4402
PN
371 } else if (!strcmp(argv[i],"-r")) {
372 if (lastarg) goto invalid;
57172ffb 373 config.randomkeys = 1;
39bf4402 374 config.randomkeys_keyspacelen = atoi(argv[++i]);
ecfaf6da 375 if (config.randomkeys_keyspacelen < 0)
376 config.randomkeys_keyspacelen = 0;
ed9b544e 377 } else if (!strcmp(argv[i],"-q")) {
378 config.quiet = 1;
379 } else if (!strcmp(argv[i],"-l")) {
380 config.loop = 1;
266373b2 381 } else if (!strcmp(argv[i],"-I")) {
382 config.idlemode = 1;
39bf4402
PN
383 } else if (!strcmp(argv[i],"--help")) {
384 exit_status = 0;
385 goto usage;
ed9b544e 386 } else {
39bf4402
PN
387 /* Assume the user meant to provide an option when the arg starts
388 * with a dash. We're done otherwise and should use the remainder
389 * as the command and arguments for running the benchmark. */
390 if (argv[i][0] == '-') goto invalid;
391 return i;
ed9b544e 392 }
393 }
39bf4402
PN
394
395 return i;
396
397invalid:
398 printf("Invalid option \"%s\" or option argument missing\n\n",argv[i]);
399
400usage:
401 printf("Usage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>]\n\n");
402 printf(" -h <hostname> Server hostname (default 127.0.0.1)\n");
403 printf(" -p <port> Server port (default 6379)\n");
404 printf(" -s <socket> Server socket (overrides host and port)\n");
405 printf(" -c <clients> Number of parallel connections (default 50)\n");
406 printf(" -n <requests> Total number of requests (default 10000)\n");
407 printf(" -d <size> Data size of SET/GET value in bytes (default 2)\n");
408 printf(" -k <boolean> 1=keep alive 0=reconnect (default 1)\n");
409 printf(" -r <keyspacelen> Use random keys for SET/GET/INCR, random values for SADD\n");
410 printf(" Using this option the benchmark will get/set keys\n");
411 printf(" in the form mykey_rand000000012456 instead of constant\n");
412 printf(" keys, the <keyspacelen> argument determines the max\n");
413 printf(" number of values for the random number. For instance\n");
414 printf(" if set to 10 only rand000000000000 - rand000000000009\n");
415 printf(" range will be allowed.\n");
416 printf(" -q Quiet. Just show query/sec values\n");
417 printf(" -l Loop. Run the tests forever\n");
418 printf(" -I Idle mode. Just open N idle connections and wait.\n");
39bf4402 419 exit(exit_status);
ed9b544e 420}
421
ed0dd554
PN
422int showThroughput(struct aeEventLoop *eventLoop, long long id, void *clientData) {
423 REDIS_NOTUSED(eventLoop);
424 REDIS_NOTUSED(id);
425 REDIS_NOTUSED(clientData);
426
427 float dt = (float)(mstime()-config.start)/1000.0;
bdbf3acf 428 float rps = (float)config.requests_finished/dt;
ed0dd554
PN
429 printf("%s: %.2f\r", config.title, rps);
430 fflush(stdout);
431 return 250; /* every 250ms */
432}
433
fc05e8c8 434int main(int argc, const char **argv) {
174df6fe 435 int i;
39bf4402
PN
436 char *data, *cmd;
437 int len;
438
ed9b544e 439 client c;
440
441 signal(SIGHUP, SIG_IGN);
442 signal(SIGPIPE, SIG_IGN);
443
444 config.numclients = 50;
445 config.requests = 10000;
446 config.liveclients = 0;
447 config.el = aeCreateEventLoop();
ed0dd554 448 aeCreateTimeEvent(config.el,1,showThroughput,NULL,NULL);
ed9b544e 449 config.keepalive = 1;
ed9b544e 450 config.datasize = 3;
57172ffb 451 config.randomkeys = 0;
ecfaf6da 452 config.randomkeys_keyspacelen = 0;
ed9b544e 453 config.quiet = 0;
454 config.loop = 0;
266373b2 455 config.idlemode = 0;
ed9b544e 456 config.latency = NULL;
457 config.clients = listCreate();
ed9b544e 458 config.hostip = "127.0.0.1";
459 config.hostport = 6379;
c61e6925 460 config.hostsocket = NULL;
ed9b544e 461
39bf4402
PN
462 i = parseOptions(argc,argv);
463 argc -= i;
464 argv += i;
465
8146e316 466 config.latency = zmalloc(sizeof(long long)*config.requests);
ed9b544e 467
468 if (config.keepalive == 0) {
c3251497 469 printf("WARNING: keepalive disabled, you probably need 'echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse' for Linux and 'sudo sysctl -w net.inet.tcp.msl=1000' for Mac OS X in order to use a lot of clients/requests\n");
ed9b544e 470 }
471
266373b2 472 if (config.idlemode) {
473 printf("Creating %d idle connections and waiting forever (Ctrl+C when done)\n", config.numclients);
3c49070b 474 c = createClient("",0); /* will never receive a reply */
266373b2 475 createMissingClients(c);
476 aeMain(config.el);
477 /* and will wait for every */
478 }
479
39bf4402
PN
480 /* Run benchmark with command in the remainder of the arguments. */
481 if (argc) {
482 sds title = sdsnew(argv[0]);
483 for (i = 1; i < argc; i++) {
484 title = sdscatlen(title, " ", 1);
294cd536 485 title = sdscatlen(title, (char*)argv[i], strlen(argv[i]));
39bf4402
PN
486 }
487
488 do {
489 len = redisFormatCommandArgv(&cmd,argc,argv,NULL);
490 benchmark(title,cmd,len);
491 free(cmd);
492 } while(config.loop);
1cd3c1e0 493
39bf4402
PN
494 return 0;
495 }
496
497 /* Run default benchmark suite. */
498 do {
1cd3c1e0 499 data = zmalloc(config.datasize+1);
174df6fe
PN
500 memset(data,'x',config.datasize);
501 data[config.datasize] = '\0';
502
f2f2424e 503 benchmark("PING (inline)","PING\r\n",6);
6766f45e 504
1cd3c1e0 505 len = redisFormatCommand(&cmd,"PING");
f2f2424e
PN
506 benchmark("PING",cmd,len);
507 free(cmd);
508
d69a4835 509 const char *argv[21];
f2f2424e 510 argv[0] = "MSET";
d69a4835
PN
511 for (i = 1; i < 21; i += 2) {
512 argv[i] = "foo:rand:000000000000";
513 argv[i+1] = data;
514 }
515 len = redisFormatCommandArgv(&cmd,21,argv,NULL);
f2f2424e 516 benchmark("MSET (10 keys)",cmd,len);
1cd3c1e0 517 free(cmd);
ea5b7092 518
1cd3c1e0 519 len = redisFormatCommand(&cmd,"SET foo:rand:000000000000 %s",data);
f2f2424e 520 benchmark("SET",cmd,len);
1cd3c1e0 521 free(cmd);
ed9b544e 522
1cd3c1e0 523 len = redisFormatCommand(&cmd,"GET foo:rand:000000000000");
f2f2424e 524 benchmark("GET",cmd,len);
1cd3c1e0 525 free(cmd);
ed9b544e 526
1cd3c1e0 527 len = redisFormatCommand(&cmd,"INCR counter:rand:000000000000");
f2f2424e 528 benchmark("INCR",cmd,len);
1cd3c1e0 529 free(cmd);
ed9b544e 530
1cd3c1e0 531 len = redisFormatCommand(&cmd,"LPUSH mylist %s",data);
f2f2424e 532 benchmark("LPUSH",cmd,len);
1cd3c1e0 533 free(cmd);
ed9b544e 534
1cd3c1e0 535 len = redisFormatCommand(&cmd,"LPOP mylist");
f2f2424e 536 benchmark("LPOP",cmd,len);
1cd3c1e0 537 free(cmd);
ed9b544e 538
1cd3c1e0 539 len = redisFormatCommand(&cmd,"SADD myset counter:rand:000000000000");
f2f2424e 540 benchmark("SADD",cmd,len);
1cd3c1e0 541 free(cmd);
b1ad58ed 542
1cd3c1e0 543 len = redisFormatCommand(&cmd,"SPOP myset");
f2f2424e 544 benchmark("SPOP",cmd,len);
1cd3c1e0 545 free(cmd);
b1ad58ed 546
1cd3c1e0 547 len = redisFormatCommand(&cmd,"LPUSH mylist %s",data);
f2f2424e 548 benchmark("LPUSH (again, in order to bench LRANGE)",cmd,len);
1cd3c1e0 549 free(cmd);
2fd30952 550
1cd3c1e0 551 len = redisFormatCommand(&cmd,"LRANGE mylist 0 99");
f2f2424e 552 benchmark("LRANGE (first 100 elements)",cmd,len);
1cd3c1e0 553 free(cmd);
2fd30952 554
1cd3c1e0 555 len = redisFormatCommand(&cmd,"LRANGE mylist 0 299");
f2f2424e 556 benchmark("LRANGE (first 300 elements)",cmd,len);
1cd3c1e0 557 free(cmd);
ccb5332c 558
1cd3c1e0 559 len = redisFormatCommand(&cmd,"LRANGE mylist 0 449");
f2f2424e 560 benchmark("LRANGE (first 450 elements)",cmd,len);
1cd3c1e0 561 free(cmd);
cc30e368 562
1cd3c1e0 563 len = redisFormatCommand(&cmd,"LRANGE mylist 0 599");
f2f2424e 564 benchmark("LRANGE (first 600 elements)",cmd,len);
1cd3c1e0 565 free(cmd);
cc30e368 566
ed9b544e 567 printf("\n");
568 } while(config.loop);
569
570 return 0;
571}