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