Skip to content

Commit

Permalink
Print out the command name
Browse files Browse the repository at this point in the history
Allow the user to specify the opcode by name or value

Change-Id: I5898257224b1d4786de4349fa93b2a94eca0755d
Reviewed-on: http://review.couchbase.org/35051
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
  • Loading branch information
trondn committed Mar 28, 2014
1 parent bd1ef70 commit d4ae896
Show file tree
Hide file tree
Showing 4 changed files with 466 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Expand Up @@ -113,7 +113,8 @@ ADD_EXECUTABLE(mcstat programs/mcstat.c
programs/utilities.h)
ADD_EXECUTABLE(mctimings programs/mctimings.c
programs/utilities.c
programs/utilities.h)
programs/utilities.h
utilities/protocol2text.c)

ADD_EXECUTABLE(mchello programs/mchello.c
programs/utilities.c
Expand Down
27 changes: 23 additions & 4 deletions programs/mctimings.c
Expand Up @@ -11,7 +11,7 @@
#include <cJSON.h>

#include "utilities.h"

#include "utilities/protocol2text.h"

typedef struct timings_st {
uint32_t max;
Expand Down Expand Up @@ -184,9 +184,28 @@ static void request_timings(BIO *bio, uint8_t opcode)
json2internal(json);

if (timings.max == 0) {
fprintf(stdout, "The server don't have information about opcode %u\n",
opcode);
const char *cmd = memcached_opcode_2_text(opcode);
if (cmd) {
fprintf(stdout,
"The server don't have information about \"%s\"\n",
cmd);
} else {
fprintf(stdout,
"The server don't have information about opcode %u\n",
opcode);
}
} else {
const char *cmd = memcached_opcode_2_text(opcode);
if (cmd) {
fprintf(stdout,
"The following data is collected for \"%s\"\n",
cmd);
} else {
fprintf(stdout,
"The following data is collected for opcode %u\n",
opcode);
}

dump_histogram();
}

Expand Down Expand Up @@ -241,7 +260,7 @@ int main(int argc, char** argv) {
}

for (; optind < argc; ++optind) {
request_timings(bio, atoi(argv[optind]));
request_timings(bio, memcached_text_2_opcode(argv[optind]));
}

BIO_free_all(bio);
Expand Down

0 comments on commit d4ae896

Please sign in to comment.