Skip to content

Commit aabf965

Browse files
committed
adding --randomize
1 parent f6f6382 commit aabf965

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

client.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,15 @@ bool client::setup_client(benchmark_config *config, abstract_protocol *protocol,
132132

133133
m_obj_gen = objgen->clone();
134134
assert(m_obj_gen != NULL);
135-
if (config->distinct_client_seed)
135+
136+
if (config->distinct_client_seed && config->randomize)
137+
m_obj_gen->set_random_seed(config->randomize + config->next_client_idx);
138+
else if (config->randomize)
139+
m_obj_gen->set_random_seed(config->randomize);
140+
else if (config->distinct_client_seed)
136141
m_obj_gen->set_random_seed(config->next_client_idx);
137-
if (config->key_pattern[0]=='P')
138-
{
142+
143+
if (config->key_pattern[0]=='P') {
139144
int range = (config->key_maximum - config->key_minimum)/(config->clients*config->threads) + 1;
140145
int min = config->key_minimum + range*config->next_client_idx;
141146
int max = min+range;

memtier_benchmark.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
219219
o_show_config,
220220
o_hide_histogram,
221221
o_distinct_client_seed,
222+
o_randomize,
222223
o_client_stats,
223224
o_reconnect_interval,
224225
o_generate_keys,
@@ -239,6 +240,7 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
239240
{ "show-config", 0, 0, o_show_config },
240241
{ "hide-histogram", 0, 0, o_hide_histogram },
241242
{ "distinct-client-seed", 0, 0, o_distinct_client_seed },
243+
{ "randomize", 0, 0, o_randomize },
242244
{ "requests", 1, 0, 'n' },
243245
{ "clients", 1, 0, 'c' },
244246
{ "threads", 1, 0, 't' },
@@ -338,6 +340,9 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
338340
case o_distinct_client_seed:
339341
cfg->distinct_client_seed++;
340342
break;
343+
case o_randomize:
344+
cfg->randomize = (int)time(NULL);
345+
break;
341346
case 'n':
342347
endptr = NULL;
343348
if (strcmp(optarg, "allkeys")==0)
@@ -572,6 +577,7 @@ void usage() {
572577
" on the protocol can be PASSWORD or USER:PASSWORD.\n"
573578
" --select-db=DB DB number to select, when testing a redis server\n"
574579
" --distinct-client-seed Use a different random seed for each client\n"
580+
" --randomize random seed based on timestamp (defalut is constant value)\n"
575581
"\n"
576582
"Object Options:\n"
577583
" -d --data-size=SIZE Object data size (default: 32)\n"

memtier_benchmark.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ struct benchmark_config {
4343
int show_config;
4444
int hide_histogram;
4545
int distinct_client_seed;
46+
int randomize;
4647
int next_client_idx;
4748
unsigned int requests;
4849
unsigned int clients;

0 commit comments

Comments
 (0)