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