typedef struct _client {
redisContext *context;
sds obuf;
- char *randptr[10]; /* needed for MSET against 10 keys */
+ char *randptr[32]; /* needed for MSET against 10 keys */
size_t randlen;
unsigned int written; /* bytes of 'obuf' already written */
long long start; /* start time of a request */
exit(1);
}
+ freeReplyObject(reply);
+
if (config.requests_finished < config.requests)
config.latency[config.requests_finished++] = c->latency;
c->pending--;
- if (c->pending == 0) clientDone(c);
+ if (c->pending == 0) {
+ clientDone(c);
+ break;
+ }
} else {
break;
}
fprintf(stderr,"%s: %s\n",config.hostsocket,c->context->errstr);
exit(1);
}
+ /* Suppress hiredis cleanup of unused buffers for max speed. */
+ c->context->reader->maxbuf = 0;
/* Queue N requests accordingly to the pipeline size. */
c->obuf = sdsempty();
for (j = 0; j < config.pipeline; j++)
/* Find substrings in the output buffer that need to be randomized. */
if (config.randomkeys) {
- char *p = c->obuf, *newline;
+ char *p = c->obuf;
while ((p = strstr(p,":rand:")) != NULL) {
- newline = strstr(p,"\r\n");
- assert(newline-(p+6) == 12); /* 12 chars for randomness */
assert(c->randlen < (signed)(sizeof(c->randptr)/sizeof(char*)));
c->randptr[c->randlen++] = p+6;
- p = newline+2;
+ p += 6;
}
}
int n = 0;
while(config.liveclients < config.numclients) {
- createClient(c->obuf,sdslen(c->obuf));
+ createClient(c->obuf,sdslen(c->obuf)/config.pipeline);
/* Listen backlog is quite limited on most systems */
if (++n > 64) {