mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
debug mode in redis-bench
This commit is contained in:
parent
7ea870c092
commit
58cd710344
15
benchmark.c
15
benchmark.c
@ -59,6 +59,7 @@
|
|||||||
#define REDIS_NOTUSED(V) ((void) V)
|
#define REDIS_NOTUSED(V) ((void) V)
|
||||||
|
|
||||||
static struct config {
|
static struct config {
|
||||||
|
int debug;
|
||||||
int numclients;
|
int numclients;
|
||||||
int requests;
|
int requests;
|
||||||
int liveclients;
|
int liveclients;
|
||||||
@ -86,6 +87,7 @@ typedef struct _client {
|
|||||||
sds ibuf;
|
sds ibuf;
|
||||||
int mbulk; /* Number of elements in an mbulk reply */
|
int mbulk; /* Number of elements in an mbulk reply */
|
||||||
int readlen; /* readlen == -1 means read a single line */
|
int readlen; /* readlen == -1 means read a single line */
|
||||||
|
int totreceived;
|
||||||
unsigned int written; /* bytes of 'obuf' already written */
|
unsigned int written; /* bytes of 'obuf' already written */
|
||||||
int replytype;
|
int replytype;
|
||||||
long long start; /* start time in milliseconds */
|
long long start; /* start time in milliseconds */
|
||||||
@ -141,6 +143,7 @@ static void resetClient(client c) {
|
|||||||
c->replytype == REPLY_MBULK) ? -1 : 0;
|
c->replytype == REPLY_MBULK) ? -1 : 0;
|
||||||
c->mbulk = -1;
|
c->mbulk = -1;
|
||||||
c->written = 0;
|
c->written = 0;
|
||||||
|
c->totreceived = 0;
|
||||||
c->state = CLIENT_SENDQUERY;
|
c->state = CLIENT_SENDQUERY;
|
||||||
c->start = mstime();
|
c->start = mstime();
|
||||||
createMissingClients(c);
|
createMissingClients(c);
|
||||||
@ -174,12 +177,18 @@ static void prepareClientForReply(client c, int type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void clientDone(client c) {
|
static void clientDone(client c) {
|
||||||
|
static int last_tot_received = 1;
|
||||||
|
|
||||||
long long latency;
|
long long latency;
|
||||||
config.donerequests ++;
|
config.donerequests ++;
|
||||||
latency = mstime() - c->start;
|
latency = mstime() - c->start;
|
||||||
if (latency > MAX_LATENCY) latency = MAX_LATENCY;
|
if (latency > MAX_LATENCY) latency = MAX_LATENCY;
|
||||||
config.latency[latency]++;
|
config.latency[latency]++;
|
||||||
|
|
||||||
|
if (config.debug && last_tot_received != c->totreceived) {
|
||||||
|
printf("Tot bytes received: %d\n", c->totreceived);
|
||||||
|
last_tot_received = c->totreceived;
|
||||||
|
}
|
||||||
if (config.donerequests == config.requests) {
|
if (config.donerequests == config.requests) {
|
||||||
freeClient(c);
|
freeClient(c);
|
||||||
aeStop(config.el);
|
aeStop(config.el);
|
||||||
@ -216,6 +225,7 @@ static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask)
|
|||||||
freeClient(c);
|
freeClient(c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
c->totreceived += nread;
|
||||||
c->ibuf = sdscatlen(c->ibuf,buf,nread);
|
c->ibuf = sdscatlen(c->ibuf,buf,nread);
|
||||||
|
|
||||||
processdata:
|
processdata:
|
||||||
@ -340,6 +350,7 @@ static client createClient(void) {
|
|||||||
c->mbulk = -1;
|
c->mbulk = -1;
|
||||||
c->readlen = 0;
|
c->readlen = 0;
|
||||||
c->written = 0;
|
c->written = 0;
|
||||||
|
c->totreceived = 0;
|
||||||
c->state = CLIENT_CONNECTING;
|
c->state = CLIENT_CONNECTING;
|
||||||
aeCreateFileEvent(config.el, c->fd, AE_WRITABLE, writeHandler, c, NULL);
|
aeCreateFileEvent(config.el, c->fd, AE_WRITABLE, writeHandler, c, NULL);
|
||||||
config.liveclients++;
|
config.liveclients++;
|
||||||
@ -440,6 +451,8 @@ void parseOptions(int argc, char **argv) {
|
|||||||
config.quiet = 1;
|
config.quiet = 1;
|
||||||
} else if (!strcmp(argv[i],"-l")) {
|
} else if (!strcmp(argv[i],"-l")) {
|
||||||
config.loop = 1;
|
config.loop = 1;
|
||||||
|
} else if (!strcmp(argv[i],"-D")) {
|
||||||
|
config.debug = 1;
|
||||||
} else {
|
} else {
|
||||||
printf("Wrong option '%s' or option argument missing\n\n",argv[i]);
|
printf("Wrong option '%s' or option argument missing\n\n",argv[i]);
|
||||||
printf("Usage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>]\n\n");
|
printf("Usage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>]\n\n");
|
||||||
@ -458,6 +471,7 @@ void parseOptions(int argc, char **argv) {
|
|||||||
printf(" range will be allowed.\n");
|
printf(" range will be allowed.\n");
|
||||||
printf(" -q Quiet. Just show query/sec values\n");
|
printf(" -q Quiet. Just show query/sec values\n");
|
||||||
printf(" -l Loop. Run the tests forever\n");
|
printf(" -l Loop. Run the tests forever\n");
|
||||||
|
printf(" -D Debug mode. more verbose.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -469,6 +483,7 @@ int main(int argc, char **argv) {
|
|||||||
signal(SIGHUP, SIG_IGN);
|
signal(SIGHUP, SIG_IGN);
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
|
||||||
|
config.debug = 0;
|
||||||
config.numclients = 50;
|
config.numclients = 50;
|
||||||
config.requests = 10000;
|
config.requests = 10000;
|
||||||
config.liveclients = 0;
|
config.liveclients = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user