Skip to content

Commit

Permalink
add print frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghenshui committed Jun 11, 2020
1 parent d6b9811 commit 5798c60
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ AM_INIT_AUTOMAKE
AM_SILENT_RULES([yes])
LT_INIT

CXXFLAGS="-O2 -g -Wall"
CXXFLAGS="-O2 -g -Wall -static-libgcc -static-libstdc++"

# Checks for programs.
AC_PROG_CXX
Expand Down
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

0 comments on commit 5798c60

Please sign in to comment.