Skip to content

Commit

Permalink
adding --randomize
Browse files Browse the repository at this point in the history
  • Loading branch information
oranagra committed Mar 18, 2015
1 parent f6f6382 commit aabf965
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
11 changes: 8 additions & 3 deletions client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,15 @@ bool client::setup_client(benchmark_config *config, abstract_protocol *protocol,

m_obj_gen = objgen->clone();
assert(m_obj_gen != NULL);
if (config->distinct_client_seed)

if (config->distinct_client_seed && config->randomize)
m_obj_gen->set_random_seed(config->randomize + config->next_client_idx);
else if (config->randomize)
m_obj_gen->set_random_seed(config->randomize);
else if (config->distinct_client_seed)
m_obj_gen->set_random_seed(config->next_client_idx);
if (config->key_pattern[0]=='P')
{

if (config->key_pattern[0]=='P') {
int range = (config->key_maximum - config->key_minimum)/(config->clients*config->threads) + 1;
int min = config->key_minimum + range*config->next_client_idx;
int max = min+range;
Expand Down
6 changes: 6 additions & 0 deletions memtier_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
o_show_config,
o_hide_histogram,
o_distinct_client_seed,
o_randomize,
o_client_stats,
o_reconnect_interval,
o_generate_keys,
Expand All @@ -239,6 +240,7 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
{ "show-config", 0, 0, o_show_config },
{ "hide-histogram", 0, 0, o_hide_histogram },
{ "distinct-client-seed", 0, 0, o_distinct_client_seed },
{ "randomize", 0, 0, o_randomize },
{ "requests", 1, 0, 'n' },
{ "clients", 1, 0, 'c' },
{ "threads", 1, 0, 't' },
Expand Down Expand Up @@ -338,6 +340,9 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
case o_distinct_client_seed:
cfg->distinct_client_seed++;
break;
case o_randomize:
cfg->randomize = (int)time(NULL);
break;
case 'n':
endptr = NULL;
if (strcmp(optarg, "allkeys")==0)
Expand Down Expand Up @@ -572,6 +577,7 @@ void usage() {
" on the protocol can be PASSWORD or USER:PASSWORD.\n"
" --select-db=DB DB number to select, when testing a redis server\n"
" --distinct-client-seed Use a different random seed for each client\n"
" --randomize random seed based on timestamp (defalut is constant value)\n"
"\n"
"Object Options:\n"
" -d --data-size=SIZE Object data size (default: 32)\n"
Expand Down
1 change: 1 addition & 0 deletions memtier_benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct benchmark_config {
int show_config;
int hide_histogram;
int distinct_client_seed;
int randomize;
int next_client_idx;
unsigned int requests;
unsigned int clients;
Expand Down

0 comments on commit aabf965

Please sign in to comment.