diff options
author | antirez <antirez@gmail.com> | 2016-07-12 11:22:41 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2016-07-12 11:23:31 +0200 |
commit | 2a1247309a63dc5a0e1593a3a89b78c0e17645d2 (patch) | |
tree | dd49debe822f16bcdd23f8af3e164e3a94c8b07e | |
parent | 382991f82ee1cc213e4225ce5f28284974715def (diff) | |
download | redis-2a1247309a63dc5a0e1593a3a89b78c0e17645d2.tar.gz |
redis-benchmark: new option to show server errors on stdout.
Disabled by default, can be activated with -e. Maybe the reverse was
more safe but departs from the past behavior.
-rw-r--r-- | src/redis-benchmark.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c index 2829df913..50905c872 100644 --- a/src/redis-benchmark.c +++ b/src/redis-benchmark.c @@ -65,6 +65,7 @@ static struct config { int randomkeys_keyspacelen; int keepalive; int pipeline; + int showerrors; long long start; long long totlatency; long long *latency; @@ -212,6 +213,16 @@ static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask) { exit(1); } + if (config.showerrors) { + static time_t lasterr_time = 0; + time_t now = time(NULL); + redisReply *r = reply; + if (r->type == REDIS_REPLY_ERROR && lasterr_time != now) { + lasterr_time = now; + printf("Error from server: %s\n", r->str); + } + } + freeReplyObject(reply); /* This is an OK for prefix commands such as auth and select.*/ if (c->prefix_pending > 0) { @@ -227,7 +238,7 @@ static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask) { c->randptr[j] -= c->prefixlen; c->prefixlen = 0; } - continue; + continue; } if (config.requests_finished < config.requests) @@ -518,6 +529,8 @@ int parseOptions(int argc, const char **argv) { config.loop = 1; } else if (!strcmp(argv[i],"-I")) { config.idlemode = 1; + } else if (!strcmp(argv[i],"-e")) { + config.showerrors = 1; } else if (!strcmp(argv[i],"-t")) { if (lastarg) goto invalid; /* We get the list of tests to run as a string in the form @@ -569,6 +582,8 @@ usage: " is executed. Default tests use this to hit random keys in the\n" " specified range.\n" " -P <numreq> Pipeline <numreq> requests. Default 1 (no pipeline).\n" +" -e If server replies with errors, show them on stdout.\n" +" (no more than 1 error per second is displayed)\n" " -q Quiet. Just show query/sec values\n" " --csv Output in CSV format\n" " -l Loop. Run the tests forever\n" @@ -649,6 +664,7 @@ int main(int argc, const char **argv) { config.keepalive = 1; config.datasize = 3; config.pipeline = 1; + config.showerrors = 0; config.randomkeys = 0; config.randomkeys_keyspacelen = 0; config.quiet = 0; |