Skip to content

Commit 5798c60

Browse files
committed
add print frequency
1 parent d6b9811 commit 5798c60

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ AM_INIT_AUTOMAKE
2323
AM_SILENT_RULES([yes])
2424
LT_INIT
2525

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

2828
# Checks for programs.
2929
AC_PROG_CXX

memtier_benchmark.cpp

+16-2
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
390390
static struct option long_options[] = {
391391
{ "server", 1, 0, 's' },
392392
{ "port", 1, 0, 'p' },
393+
{ "print-frequency", 1, 0, 'f' },
393394
{ "unix-socket", 1, 0, 'S' },
394395
{ "protocol", 1, 0, 'P' },
395396
#ifdef USE_TLS
@@ -453,7 +454,7 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
453454
int c;
454455
char *endptr;
455456
while ((c = getopt_long(argc, argv,
456-
"s:S:p:P:o:x:DRn:c:t:d:a:h", long_options, &option_index)) != -1)
457+
"s:S:p:P:f:o:x:DRn:c:t:d:a:h", long_options, &option_index)) != -1)
457458
{
458459
switch (c) {
459460
case 'h':
@@ -481,6 +482,14 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
481482
return -1;
482483
}
483484
break;
485+
case 'f':
486+
endptr = NULL;
487+
cfg->print_frequency_every_seconds = (int) strtoul(optarg, &endptr, 10);
488+
if (cfg->print_frequency_every_seconds < 0 || !endptr || *endptr != '\0') {
489+
fprintf(stderr, "error: print_frequency_every_seconds must be greater than zero.\n");
490+
return -1;
491+
}
492+
break;
484493
case 'P':
485494
if (strcmp(optarg, "memcache_text") &&
486495
strcmp(optarg, "memcache_binary") &&
@@ -845,6 +854,7 @@ void usage() {
845854
" and Redis <= 5.x. <USER>:<PASSWORD> can be\n"
846855
" specified for memcache_binary or Redis 6.x\n"
847856
" or newer with ACL user support.\n"
857+
" -f, --print-frequency print frequncy (default: 1)\n"
848858
#ifdef USE_TLS
849859
" --tls Enable SSL/TLS transport security\n"
850860
" --cert=FILE Use specified client certificate for TLS\n"
@@ -1047,7 +1057,11 @@ run_stats run_benchmark(int run_id, benchmark_config* cfg, object_generator* obj
10471057
unsigned int active_threads = 0;
10481058
do {
10491059
active_threads = 0;
1050-
sleep(1);
1060+
if (cfg->print_frequency_every_seconds) {
1061+
sleep(cfg->print_frequency_every_seconds);
1062+
} else {
1063+
sleep(1);
1064+
}
10511065

10521066
unsigned long int total_ops = 0;
10531067
unsigned long int total_bytes = 0;

memtier_benchmark.h

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ struct benchmark_config {
9393
const char *json_out_file;
9494
bool cluster_mode;
9595
struct arbitrary_command_list* arbitrary_commands;
96+
int print_frequency_every_seconds;
9697
#ifdef USE_TLS
9798
bool tls;
9899
const char *tls_cert;

0 commit comments

Comments
 (0)