7 long int timedif(struct timeval a
, struct timeval b
)
11 us
= a
.tv_usec
- b
.tv_usec
;
13 s
= a
.tv_sec
- b
.tv_sec
;
18 void version_command(char *command_name
)
20 printf("%s v%u.%u\n", command_name
, 1, 0);
24 static char *lookup_help(memcached_options option
)
28 case OPT_SERVERS
: return("List which servers you wish to connect to.");
29 case OPT_VERSION
: return("Display the version of the application and then exit.");
30 case OPT_HELP
: return("Diplay this message and then exit.");
31 case OPT_VERBOSE
: return("Give more details on the progression of the application.");
32 case OPT_DEBUG
: return("Provide output only useful for debugging.");
33 case OPT_FLAG
: return("Provide flag information for storage operation.");
34 case OPT_EXPIRE
: return("Set the expire option for the object.");
35 case OPT_SET
: return("Use set command with memcached when storing.");
36 case OPT_REPLACE
: return("Use replace command with memcached when storing.");
37 case OPT_ADD
: return("Use add command with memcached when storing.");
38 case OPT_SLAP_EXECUTE_NUMBER
: return("Number of times to execute the given test.");
39 case OPT_SLAP_INITIAL_LOAD
: return("Number of key pairs to load before executing tests.");
40 case OPT_SLAP_TEST
: return("Test to run (currently \"get\" or \"set\").");
41 case OPT_SLAP_CONCURRENCY
: return("Number of users to simulate with load.");
42 case OPT_SLAP_NON_BLOCK
: return("Set TCP up to use non-blocking IO.");
43 case OPT_SLAP_TCP_NODELAY
: return("Set TCP socket up to use nodelay.");
44 case OPT_FLUSH
: return("Flush servers before running tests.");
45 case OPT_HASH
: return("Select hash type.");
46 case OPT_BINARY
: return("Switch to binary protocol.");
47 case OPT_ANALYZE
: return("Analyze the provided servers.");
48 case OPT_UDP
: return("Use UDP protocol when communicating with server.");
52 return "forgot to document this function :)";
55 void help_command(char *command_name
, char *description
,
56 const struct option
*long_options
,
57 memcached_programs_help_st
*options
__attribute__((unused
)))
61 printf("%s v%u.%u\n\n", command_name
, 1, 0);
62 printf("\t%s\n\n", description
);
63 printf("Current options. A '=' means the option takes a value.\n\n");
65 for (x
= 0; long_options
[x
].name
; x
++)
69 printf("\t --%s%c\n", long_options
[x
].name
,
70 long_options
[x
].has_arg
? '=' : ' ');
71 if ((help_message
= lookup_help(long_options
[x
].val
)))
72 printf("\t\t%s\n", help_message
);
79 void process_hash_option(memcached_st
*memc
, char *opt_hash
)
87 set
= MEMCACHED_HASH_DEFAULT
; /* Just here to solve warning */
88 if (!strcasecmp(opt_hash
, "CRC"))
89 set
= MEMCACHED_HASH_CRC
;
90 else if (!strcasecmp(opt_hash
, "FNV1_64"))
91 set
= MEMCACHED_HASH_FNV1_64
;
92 else if (!strcasecmp(opt_hash
, "FNV1A_64"))
93 set
= MEMCACHED_HASH_FNV1A_64
;
94 else if (!strcasecmp(opt_hash
, "FNV1_32"))
95 set
= MEMCACHED_HASH_FNV1_32
;
96 else if (!strcasecmp(opt_hash
, "FNV1A_32"))
97 set
= MEMCACHED_HASH_FNV1A_32
;
100 fprintf(stderr
, "hash: type not recognized %s\n", opt_hash
);
104 rc
= memcached_behavior_set(memc
, MEMCACHED_BEHAVIOR_HASH
, set
);
105 if (rc
!= MEMCACHED_SUCCESS
)
107 fprintf(stderr
, "hash: memcache error %s\n", memcached_strerror(memc
, rc
));