]> git.saurik.com Git - redis.git/blob - src/redis-benchmark.c
sockaddr_un.sun_path appears to never hold anything after accept()
[redis.git] / src / redis-benchmark.c
1 /* Redis benchmark utility.
2 *
3 * Copyright (c) 2009-2010, Salvatore Sanfilippo <antirez at gmail dot com>
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
31 #include "fmacros.h"
32
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"
43 #include "anet.h"
44 #include "sds.h"
45 #include "adlist.h"
46 #include "zmalloc.h"
47
48 #define REPLY_INT 0
49 #define REPLY_RETCODE 1
50 #define REPLY_BULK 2
51 #define REPLY_MBULK 3
52
53 #define CLIENT_CONNECTING 0
54 #define CLIENT_SENDQUERY 1
55 #define CLIENT_READREPLY 2
56
57 #define MAX_LATENCY 5000
58
59 #define REDIS_NOTUSED(V) ((void) V)
60
61 static struct config {
62 int debug;
63 int numclients;
64 int requests;
65 int liveclients;
66 int donerequests;
67 int keysize;
68 int datasize;
69 int randomkeys;
70 int randomkeys_keyspacelen;
71 aeEventLoop *el;
72 char *hostip;
73 int hostport;
74 char *hostsocket;
75 int keepalive;
76 long long start;
77 long long totlatency;
78 int *latency;
79 list *clients;
80 int quiet;
81 int loop;
82 int idlemode;
83 } config;
84
85 typedef struct _client {
86 int state;
87 int fd;
88 sds obuf;
89 sds ibuf;
90 int mbulk; /* Number of elements in an mbulk reply */
91 int readlen; /* readlen == -1 means read a single line */
92 int totreceived;
93 unsigned int written; /* bytes of 'obuf' already written */
94 int replytype;
95 long long start; /* start time in milliseconds */
96 } *client;
97
98 /* Prototypes */
99 static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask);
100 static void createMissingClients(client c);
101
102 /* Implementation */
103 static long long mstime(void) {
104 struct timeval tv;
105 long long mst;
106
107 gettimeofday(&tv, NULL);
108 mst = ((long)tv.tv_sec)*1000;
109 mst += tv.tv_usec/1000;
110 return mst;
111 }
112
113 static void freeClient(client c) {
114 listNode *ln;
115
116 aeDeleteFileEvent(config.el,c->fd,AE_WRITABLE);
117 aeDeleteFileEvent(config.el,c->fd,AE_READABLE);
118 sdsfree(c->ibuf);
119 sdsfree(c->obuf);
120 close(c->fd);
121 zfree(c);
122 config.liveclients--;
123 ln = listSearchKey(config.clients,c);
124 assert(ln != NULL);
125 listDelNode(config.clients,ln);
126 }
127
128 static void freeAllClients(void) {
129 listNode *ln = config.clients->head, *next;
130
131 while(ln) {
132 next = ln->next;
133 freeClient(ln->value);
134 ln = next;
135 }
136 }
137
138 static void resetClient(client c) {
139 aeDeleteFileEvent(config.el,c->fd,AE_WRITABLE);
140 aeDeleteFileEvent(config.el,c->fd,AE_READABLE);
141 aeCreateFileEvent(config.el,c->fd, AE_WRITABLE,writeHandler,c);
142 sdsfree(c->ibuf);
143 c->ibuf = sdsempty();
144 c->readlen = (c->replytype == REPLY_BULK ||
145 c->replytype == REPLY_MBULK) ? -1 : 0;
146 c->mbulk = -1;
147 c->written = 0;
148 c->totreceived = 0;
149 c->state = CLIENT_SENDQUERY;
150 c->start = mstime();
151 createMissingClients(c);
152 }
153
154 static void randomizeClientKey(client c) {
155 char *p;
156 char buf[32];
157 long r;
158
159 p = strstr(c->obuf, "_rand");
160 if (!p) return;
161 p += 5;
162 r = random() % config.randomkeys_keyspacelen;
163 sprintf(buf,"%ld",r);
164 memcpy(p,buf,strlen(buf));
165 }
166
167 static void prepareClientForReply(client c, int type) {
168 if (type == REPLY_BULK) {
169 c->replytype = REPLY_BULK;
170 c->readlen = -1;
171 } else if (type == REPLY_MBULK) {
172 c->replytype = REPLY_MBULK;
173 c->readlen = -1;
174 c->mbulk = -1;
175 } else {
176 c->replytype = type;
177 c->readlen = 0;
178 }
179 }
180
181 static void clientDone(client c) {
182 static int last_tot_received = 1;
183
184 long long latency;
185 config.donerequests ++;
186 latency = mstime() - c->start;
187 if (latency > MAX_LATENCY) latency = MAX_LATENCY;
188 config.latency[latency]++;
189
190 if (config.debug && last_tot_received != c->totreceived) {
191 printf("Tot bytes received: %d\n", c->totreceived);
192 last_tot_received = c->totreceived;
193 }
194 if (config.donerequests == config.requests) {
195 freeClient(c);
196 aeStop(config.el);
197 return;
198 }
199 if (config.keepalive) {
200 resetClient(c);
201 if (config.randomkeys) randomizeClientKey(c);
202 } else {
203 config.liveclients--;
204 createMissingClients(c);
205 config.liveclients++;
206 freeClient(c);
207 }
208 }
209
210 static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask)
211 {
212 char buf[1024];
213 int nread;
214 client c = privdata;
215 REDIS_NOTUSED(el);
216 REDIS_NOTUSED(fd);
217 REDIS_NOTUSED(mask);
218
219 nread = read(c->fd, buf, 1024);
220 if (nread == -1) {
221 fprintf(stderr, "Reading from socket: %s\n", strerror(errno));
222 freeClient(c);
223 return;
224 }
225 if (nread == 0) {
226 fprintf(stderr, "EOF from client\n");
227 freeClient(c);
228 return;
229 }
230 c->totreceived += nread;
231 c->ibuf = sdscatlen(c->ibuf,buf,nread);
232
233 processdata:
234 /* Are we waiting for the first line of the command of for sdf
235 * count in bulk or multi bulk operations? */
236 if (c->replytype == REPLY_INT ||
237 c->replytype == REPLY_RETCODE ||
238 (c->replytype == REPLY_BULK && c->readlen == -1) ||
239 (c->replytype == REPLY_MBULK && c->readlen == -1) ||
240 (c->replytype == REPLY_MBULK && c->mbulk == -1)) {
241 char *p;
242
243 /* Check if the first line is complete. This is only true if
244 * there is a newline inside the buffer. */
245 if ((p = strchr(c->ibuf,'\n')) != NULL) {
246 if (c->replytype == REPLY_BULK ||
247 (c->replytype == REPLY_MBULK && c->mbulk != -1))
248 {
249 /* Read the count of a bulk reply (being it a single bulk or
250 * a multi bulk reply). "$<count>" for the protocol spec. */
251 *p = '\0';
252 *(p-1) = '\0';
253 c->readlen = atoi(c->ibuf+1)+2;
254 // printf("BULK ATOI: %s\n", c->ibuf+1);
255 /* Handle null bulk reply "$-1" */
256 if (c->readlen-2 == -1) {
257 clientDone(c);
258 return;
259 }
260 /* Leave all the rest in the input buffer */
261 c->ibuf = sdsrange(c->ibuf,(p-c->ibuf)+1,-1);
262 /* fall through to reach the point where the code will try
263 * to check if the bulk reply is complete. */
264 } else if (c->replytype == REPLY_MBULK && c->mbulk == -1) {
265 /* Read the count of a multi bulk reply. That is, how many
266 * bulk replies we have to read next. "*<count>" protocol. */
267 *p = '\0';
268 *(p-1) = '\0';
269 c->mbulk = atoi(c->ibuf+1);
270 /* Handle null bulk reply "*-1" */
271 if (c->mbulk == -1) {
272 clientDone(c);
273 return;
274 }
275 // printf("%p) %d elements list\n", c, c->mbulk);
276 /* Leave all the rest in the input buffer */
277 c->ibuf = sdsrange(c->ibuf,(p-c->ibuf)+1,-1);
278 goto processdata;
279 } else {
280 c->ibuf = sdstrim(c->ibuf,"\r\n");
281 clientDone(c);
282 return;
283 }
284 }
285 }
286 /* bulk read, did we read everything? */
287 if (((c->replytype == REPLY_MBULK && c->mbulk != -1) ||
288 (c->replytype == REPLY_BULK)) && c->readlen != -1 &&
289 (unsigned)c->readlen <= sdslen(c->ibuf))
290 {
291 // printf("BULKSTATUS mbulk:%d readlen:%d sdslen:%d\n",
292 // c->mbulk,c->readlen,sdslen(c->ibuf));
293 if (c->replytype == REPLY_BULK) {
294 clientDone(c);
295 } else if (c->replytype == REPLY_MBULK) {
296 // printf("%p) %d (%d)) ",c, c->mbulk, c->readlen);
297 // fwrite(c->ibuf,c->readlen,1,stdout);
298 // printf("\n");
299 if (--c->mbulk == 0) {
300 clientDone(c);
301 } else {
302 c->ibuf = sdsrange(c->ibuf,c->readlen,-1);
303 c->readlen = -1;
304 goto processdata;
305 }
306 }
307 }
308 }
309
310 static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask)
311 {
312 client c = privdata;
313 REDIS_NOTUSED(el);
314 REDIS_NOTUSED(fd);
315 REDIS_NOTUSED(mask);
316
317 if (c->state == CLIENT_CONNECTING) {
318 c->state = CLIENT_SENDQUERY;
319 c->start = mstime();
320 }
321 if (sdslen(c->obuf) > c->written) {
322 void *ptr = c->obuf+c->written;
323 int len = sdslen(c->obuf) - c->written;
324 int nwritten = write(c->fd, ptr, len);
325 if (nwritten == -1) {
326 if (errno != EPIPE)
327 fprintf(stderr, "Writing to socket: %s\n", strerror(errno));
328 freeClient(c);
329 return;
330 }
331 c->written += nwritten;
332 if (sdslen(c->obuf) == c->written) {
333 aeDeleteFileEvent(config.el,c->fd,AE_WRITABLE);
334 aeCreateFileEvent(config.el,c->fd,AE_READABLE,readHandler,c);
335 c->state = CLIENT_READREPLY;
336 }
337 }
338 }
339
340 static client createClient(void) {
341 client c = zmalloc(sizeof(struct _client));
342 char err[ANET_ERR_LEN];
343
344 if (config.hostsocket == NULL)
345 c->fd = anetTcpNonBlockConnect(err,config.hostip,config.hostport);
346 else
347 c->fd = anetUnixNonBlockConnect(err,config.hostsocket);
348
349 if (c->fd == ANET_ERR) {
350 zfree(c);
351 fprintf(stderr,"Connect: %s\n",err);
352 return NULL;
353 }
354 anetTcpNoDelay(NULL,c->fd);
355 c->obuf = sdsempty();
356 c->ibuf = sdsempty();
357 c->mbulk = -1;
358 c->readlen = 0;
359 c->written = 0;
360 c->totreceived = 0;
361 c->state = CLIENT_CONNECTING;
362 aeCreateFileEvent(config.el, c->fd, AE_WRITABLE, writeHandler, c);
363 config.liveclients++;
364 listAddNodeTail(config.clients,c);
365 return c;
366 }
367
368 static void createMissingClients(client c) {
369 while(config.liveclients < config.numclients) {
370 client new = createClient();
371 if (!new) continue;
372 sdsfree(new->obuf);
373 new->obuf = sdsdup(c->obuf);
374 if (config.randomkeys) randomizeClientKey(c);
375 prepareClientForReply(new,c->replytype);
376 }
377 }
378
379 static void showLatencyReport(char *title) {
380 int j, seen = 0;
381 float perc, reqpersec;
382
383 reqpersec = (float)config.donerequests/((float)config.totlatency/1000);
384 if (!config.quiet) {
385 printf("====== %s ======\n", title);
386 printf(" %d requests completed in %.2f seconds\n", config.donerequests,
387 (float)config.totlatency/1000);
388 printf(" %d parallel clients\n", config.numclients);
389 printf(" %d bytes payload\n", config.datasize);
390 printf(" keep alive: %d\n", config.keepalive);
391 printf("\n");
392 for (j = 0; j <= MAX_LATENCY; j++) {
393 if (config.latency[j]) {
394 seen += config.latency[j];
395 perc = ((float)seen*100)/config.donerequests;
396 printf("%.2f%% <= %d milliseconds\n", perc, j);
397 }
398 }
399 printf("%.2f requests per second\n\n", reqpersec);
400 } else {
401 printf("%s: %.2f requests per second\n", title, reqpersec);
402 }
403 }
404
405 static void prepareForBenchmark(void)
406 {
407 memset(config.latency,0,sizeof(int)*(MAX_LATENCY+1));
408 config.start = mstime();
409 config.donerequests = 0;
410 }
411
412 static void endBenchmark(char *title) {
413 config.totlatency = mstime()-config.start;
414 showLatencyReport(title);
415 freeAllClients();
416 }
417
418 void parseOptions(int argc, char **argv) {
419 int i;
420
421 for (i = 1; i < argc; i++) {
422 int lastarg = i==argc-1;
423
424 if (!strcmp(argv[i],"-c") && !lastarg) {
425 config.numclients = atoi(argv[i+1]);
426 i++;
427 } else if (!strcmp(argv[i],"-n") && !lastarg) {
428 config.requests = atoi(argv[i+1]);
429 i++;
430 } else if (!strcmp(argv[i],"-k") && !lastarg) {
431 config.keepalive = atoi(argv[i+1]);
432 i++;
433 } else if (!strcmp(argv[i],"-h") && !lastarg) {
434 char *ip = zmalloc(32);
435 if (anetResolve(NULL,argv[i+1],ip) == ANET_ERR) {
436 printf("Can't resolve %s\n", argv[i]);
437 exit(1);
438 }
439 config.hostip = ip;
440 i++;
441 } else if (!strcmp(argv[i],"-p") && !lastarg) {
442 config.hostport = atoi(argv[i+1]);
443 i++;
444 } else if (!strcmp(argv[i],"-s") && !lastarg) {
445 config.hostsocket = argv[i+1];
446 i++;
447 } else if (!strcmp(argv[i],"-d") && !lastarg) {
448 config.datasize = atoi(argv[i+1]);
449 i++;
450 if (config.datasize < 1) config.datasize=1;
451 if (config.datasize > 1024*1024) config.datasize = 1024*1024;
452 } else if (!strcmp(argv[i],"-r") && !lastarg) {
453 config.randomkeys = 1;
454 config.randomkeys_keyspacelen = atoi(argv[i+1]);
455 if (config.randomkeys_keyspacelen < 0)
456 config.randomkeys_keyspacelen = 0;
457 i++;
458 } else if (!strcmp(argv[i],"-q")) {
459 config.quiet = 1;
460 } else if (!strcmp(argv[i],"-l")) {
461 config.loop = 1;
462 } else if (!strcmp(argv[i],"-D")) {
463 config.debug = 1;
464 } else if (!strcmp(argv[i],"-I")) {
465 config.idlemode = 1;
466 } else {
467 printf("Wrong option '%s' or option argument missing\n\n",argv[i]);
468 printf("Usage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>]\n\n");
469 printf(" -h <hostname> Server hostname (default 127.0.0.1)\n");
470 printf(" -p <port> Server port (default 6379)\n");
471 printf(" -s <socket> Server socket (overrides host and port)\n");
472 printf(" -c <clients> Number of parallel connections (default 50)\n");
473 printf(" -n <requests> Total number of requests (default 10000)\n");
474 printf(" -d <size> Data size of SET/GET value in bytes (default 2)\n");
475 printf(" -k <boolean> 1=keep alive 0=reconnect (default 1)\n");
476 printf(" -r <keyspacelen> Use random keys for SET/GET/INCR, random values for SADD\n");
477 printf(" Using this option the benchmark will get/set keys\n");
478 printf(" in the form mykey_rand000000012456 instead of constant\n");
479 printf(" keys, the <keyspacelen> argument determines the max\n");
480 printf(" number of values for the random number. For instance\n");
481 printf(" if set to 10 only rand000000000000 - rand000000000009\n");
482 printf(" range will be allowed.\n");
483 printf(" -q Quiet. Just show query/sec values\n");
484 printf(" -l Loop. Run the tests forever\n");
485 printf(" -I Idle mode. Just open N idle connections and wait.\n");
486 printf(" -D Debug mode. more verbose.\n");
487 exit(1);
488 }
489 }
490 }
491
492 int main(int argc, char **argv) {
493 client c;
494
495 signal(SIGHUP, SIG_IGN);
496 signal(SIGPIPE, SIG_IGN);
497
498 config.debug = 0;
499 config.numclients = 50;
500 config.requests = 10000;
501 config.liveclients = 0;
502 config.el = aeCreateEventLoop();
503 config.keepalive = 1;
504 config.donerequests = 0;
505 config.datasize = 3;
506 config.randomkeys = 0;
507 config.randomkeys_keyspacelen = 0;
508 config.quiet = 0;
509 config.loop = 0;
510 config.idlemode = 0;
511 config.latency = NULL;
512 config.clients = listCreate();
513 config.latency = zmalloc(sizeof(int)*(MAX_LATENCY+1));
514
515 config.hostip = "127.0.0.1";
516 config.hostport = 6379;
517 config.hostsocket = NULL;
518
519 parseOptions(argc,argv);
520
521 if (config.keepalive == 0) {
522 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");
523 }
524
525 if (config.idlemode) {
526 printf("Creating %d idle connections and waiting forever (Ctrl+C when done)\n", config.numclients);
527 prepareForBenchmark();
528 c = createClient();
529 if (!c) exit(1);
530 c->obuf = sdsempty();
531 prepareClientForReply(c,REPLY_RETCODE); /* will never receive it */
532 createMissingClients(c);
533 aeMain(config.el);
534 /* and will wait for every */
535 }
536
537 do {
538 prepareForBenchmark();
539 c = createClient();
540 if (!c) exit(1);
541 c->obuf = sdscat(c->obuf,"PING\r\n");
542 prepareClientForReply(c,REPLY_RETCODE);
543 createMissingClients(c);
544 aeMain(config.el);
545 endBenchmark("PING");
546
547 prepareForBenchmark();
548 c = createClient();
549 if (!c) exit(1);
550 c->obuf = sdscat(c->obuf,"*1\r\n$4\r\nPING\r\n");
551 prepareClientForReply(c,REPLY_RETCODE);
552 createMissingClients(c);
553 aeMain(config.el);
554 endBenchmark("PING (multi bulk)");
555
556 prepareForBenchmark();
557 c = createClient();
558 if (!c) exit(1);
559 c->obuf = sdscatprintf(c->obuf,"SET foo_rand000000000000 %d\r\n",config.datasize);
560 {
561 char *data = zmalloc(config.datasize+2);
562 memset(data,'x',config.datasize);
563 data[config.datasize] = '\r';
564 data[config.datasize+1] = '\n';
565 c->obuf = sdscatlen(c->obuf,data,config.datasize+2);
566 }
567 prepareClientForReply(c,REPLY_RETCODE);
568 createMissingClients(c);
569 aeMain(config.el);
570 endBenchmark("SET");
571
572 prepareForBenchmark();
573 c = createClient();
574 if (!c) exit(1);
575 c->obuf = sdscat(c->obuf,"GET foo_rand000000000000\r\n");
576 prepareClientForReply(c,REPLY_BULK);
577 createMissingClients(c);
578 aeMain(config.el);
579 endBenchmark("GET");
580
581 prepareForBenchmark();
582 c = createClient();
583 if (!c) exit(1);
584 c->obuf = sdscat(c->obuf,"INCR counter_rand000000000000\r\n");
585 prepareClientForReply(c,REPLY_INT);
586 createMissingClients(c);
587 aeMain(config.el);
588 endBenchmark("INCR");
589
590 prepareForBenchmark();
591 c = createClient();
592 if (!c) exit(1);
593 c->obuf = sdscat(c->obuf,"LPUSH mylist 3\r\nbar\r\n");
594 prepareClientForReply(c,REPLY_INT);
595 createMissingClients(c);
596 aeMain(config.el);
597 endBenchmark("LPUSH");
598
599 prepareForBenchmark();
600 c = createClient();
601 if (!c) exit(1);
602 c->obuf = sdscat(c->obuf,"LPOP mylist\r\n");
603 prepareClientForReply(c,REPLY_BULK);
604 createMissingClients(c);
605 aeMain(config.el);
606 endBenchmark("LPOP");
607
608 prepareForBenchmark();
609 c = createClient();
610 if (!c) exit(1);
611 c->obuf = sdscat(c->obuf,"SADD myset 24\r\ncounter_rand000000000000\r\n");
612 prepareClientForReply(c,REPLY_RETCODE);
613 createMissingClients(c);
614 aeMain(config.el);
615 endBenchmark("SADD");
616
617 prepareForBenchmark();
618 c = createClient();
619 if (!c) exit(1);
620 c->obuf = sdscat(c->obuf,"SPOP myset\r\n");
621 prepareClientForReply(c,REPLY_BULK);
622 createMissingClients(c);
623 aeMain(config.el);
624 endBenchmark("SPOP");
625
626 prepareForBenchmark();
627 c = createClient();
628 if (!c) exit(1);
629 c->obuf = sdscat(c->obuf,"LPUSH mylist 3\r\nbar\r\n");
630 prepareClientForReply(c,REPLY_RETCODE);
631 createMissingClients(c);
632 aeMain(config.el);
633 endBenchmark("LPUSH (again, in order to bench LRANGE)");
634
635 prepareForBenchmark();
636 c = createClient();
637 if (!c) exit(1);
638 c->obuf = sdscat(c->obuf,"LRANGE mylist 0 99\r\n");
639 prepareClientForReply(c,REPLY_MBULK);
640 createMissingClients(c);
641 aeMain(config.el);
642 endBenchmark("LRANGE (first 100 elements)");
643
644 prepareForBenchmark();
645 c = createClient();
646 if (!c) exit(1);
647 c->obuf = sdscat(c->obuf,"LRANGE mylist 0 299\r\n");
648 prepareClientForReply(c,REPLY_MBULK);
649 createMissingClients(c);
650 aeMain(config.el);
651 endBenchmark("LRANGE (first 300 elements)");
652
653 prepareForBenchmark();
654 c = createClient();
655 if (!c) exit(1);
656 c->obuf = sdscat(c->obuf,"LRANGE mylist 0 449\r\n");
657 prepareClientForReply(c,REPLY_MBULK);
658 createMissingClients(c);
659 aeMain(config.el);
660 endBenchmark("LRANGE (first 450 elements)");
661
662 prepareForBenchmark();
663 c = createClient();
664 if (!c) exit(1);
665 c->obuf = sdscat(c->obuf,"LRANGE mylist 0 599\r\n");
666 prepareClientForReply(c,REPLY_MBULK);
667 createMissingClients(c);
668 aeMain(config.el);
669 endBenchmark("LRANGE (first 600 elements)");
670
671 printf("\n");
672 } while(config.loop);
673
674 return 0;
675 }