Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add print frequency #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions memtier_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
static struct option long_options[] = {
{ "server", 1, 0, 's' },
{ "port", 1, 0, 'p' },
{ "print-frequency", 1, 0, 'f' },
{ "unix-socket", 1, 0, 'S' },
{ "protocol", 1, 0, 'P' },
#ifdef USE_TLS
Expand Down Expand Up @@ -453,7 +454,7 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
int c;
char *endptr;
while ((c = getopt_long(argc, argv,
"s:S:p:P:o:x:DRn:c:t:d:a:h", long_options, &option_index)) != -1)
"s:S:p:P:f:o:x:DRn:c:t:d:a:h", long_options, &option_index)) != -1)
{
switch (c) {
case 'h':
Expand Down Expand Up @@ -481,6 +482,14 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
return -1;
}
break;
case 'f':
endptr = NULL;
cfg->print_frequency_every_seconds = (int) strtoul(optarg, &endptr, 10);
if (cfg->print_frequency_every_seconds < 0 || !endptr || *endptr != '\0') {
fprintf(stderr, "error: print_frequency_every_seconds must be greater than zero.\n");
return -1;
}
break;
case 'P':
if (strcmp(optarg, "memcache_text") &&
strcmp(optarg, "memcache_binary") &&
Expand Down Expand Up @@ -845,6 +854,7 @@ void usage() {
" and Redis <= 5.x. <USER>:<PASSWORD> can be\n"
" specified for memcache_binary or Redis 6.x\n"
" or newer with ACL user support.\n"
" -f, --print-frequency print frequncy (default: 1)\n"
#ifdef USE_TLS
" --tls Enable SSL/TLS transport security\n"
" --cert=FILE Use specified client certificate for TLS\n"
Expand Down Expand Up @@ -1047,7 +1057,11 @@ run_stats run_benchmark(int run_id, benchmark_config* cfg, object_generator* obj
unsigned int active_threads = 0;
do {
active_threads = 0;
sleep(1);
if (cfg->print_frequency_every_seconds) {
sleep(cfg->print_frequency_every_seconds);
} else {
sleep(1);
}

unsigned long int total_ops = 0;
unsigned long int total_bytes = 0;
Expand Down
1 change: 1 addition & 0 deletions memtier_benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ struct benchmark_config {
const char *json_out_file;
bool cluster_mode;
struct arbitrary_command_list* arbitrary_commands;
int print_frequency_every_seconds;
#ifdef USE_TLS
bool tls;
const char *tls_cert;
Expand Down