diff options
author | David Hows <david.hows@mongodb.com> | 2017-01-23 16:05:51 +1100 |
---|---|---|
committer | David Hows <david.hows@mongodb.com> | 2017-01-23 16:06:16 +1100 |
commit | 48a3cbc17fa902528217287fd075c87efb44aebc (patch) | |
tree | fff4f814ab9fbd7f3eb4c45684f581a5da1c058c /bench/wtperf/wtperf.c | |
parent | 8d2324943364286056ae399043f70b8a937de312 (diff) | |
parent | bf8de9767982da9ae0f1542f3744c8aa8544fb82 (diff) | |
download | mongo-48a3cbc17fa902528217287fd075c87efb44aebc.tar.gz |
Merge branch 'develop' into mongodb-3.6mongodb-3.5.3mongodb-3.5.2
Diffstat (limited to 'bench/wtperf/wtperf.c')
-rw-r--r-- | bench/wtperf/wtperf.c | 120 |
1 files changed, 84 insertions, 36 deletions
diff --git a/bench/wtperf/wtperf.c b/bench/wtperf/wtperf.c index 8c7f0053388..baa259f8817 100644 --- a/bench/wtperf/wtperf.c +++ b/bench/wtperf/wtperf.c @@ -2361,11 +2361,11 @@ main(int argc, char *argv[]) { CONFIG_OPTS *opts; WTPERF *wtperf, _wtperf; - size_t req_len, sreq_len; + size_t pos, req_len, sreq_len; bool monitor_set; int ch, ret; const char *cmdflags = "C:h:m:O:o:T:"; - const char *config_opts; + const char *append_comma, *config_opts; char *cc_buf, *path, *sess_cfg, *tc_buf, *user_cconfig, *user_tconfig; /* The first WTPERF structure (from which all others are derived). */ @@ -2502,53 +2502,101 @@ main(int argc, char *argv[]) __wt_stream_set_line_buffer(stdout); /* Concatenate non-default configuration strings. */ - if (opts->verbose > 1 || user_cconfig != NULL || - opts->session_count_idle > 0 || wtperf->compress_ext != NULL || - wtperf->async_config != NULL) { - req_len = strlen(debug_cconfig) + 20; - if (user_cconfig != NULL) - req_len += strlen(user_cconfig); - if (wtperf->async_config != NULL) - req_len += strlen(wtperf->async_config); - if (wtperf->compress_ext != NULL) - req_len += strlen(wtperf->compress_ext); + if ((opts->verbose > 1 && strlen(debug_cconfig) != 0) || + user_cconfig != NULL || opts->session_count_idle > 0 || + wtperf->compress_ext != NULL || wtperf->async_config != NULL) { + req_len = 20; + req_len += wtperf->async_config != NULL ? + strlen(wtperf->async_config) : 0; + req_len += wtperf->compress_ext != NULL ? + strlen(wtperf->compress_ext) : 0; if (opts->session_count_idle > 0) { - sreq_len = strlen(",session_max=") + 6; + sreq_len = strlen("session_max=") + 6; req_len += sreq_len; sess_cfg = dmalloc(sreq_len); snprintf(sess_cfg, sreq_len, - ",session_max=%" PRIu32, + "session_max=%" PRIu32, opts->session_count_idle + wtperf->workers_cnt + opts->populate_threads + 10); } + req_len += user_cconfig != NULL ? strlen(user_cconfig) : 0; + req_len += debug_cconfig != NULL ? strlen(debug_cconfig) : 0; cc_buf = dmalloc(req_len); - snprintf(cc_buf, req_len, "%s,%s,%s,%s,%s", - wtperf->async_config ? wtperf->async_config : "", - wtperf->compress_ext ? wtperf->compress_ext : "", - opts->verbose > 1 ? debug_cconfig : "", - sess_cfg != NULL ? sess_cfg : "", - user_cconfig != NULL ? user_cconfig : ""); - if (strlen(cc_buf) && (ret = + + pos = 0; + append_comma = ""; + if (wtperf->async_config != NULL && + strlen(wtperf->async_config) != 0) { + pos += (size_t)snprintf( + cc_buf + pos, req_len - pos, "%s%s", + append_comma, wtperf->async_config); + append_comma = ","; + } + if (wtperf->compress_ext != NULL && + strlen(wtperf->compress_ext) != 0) { + pos += (size_t)snprintf( + cc_buf + pos, req_len - pos, "%s%s", + append_comma, wtperf->compress_ext); + append_comma = ","; + } + if (sess_cfg != NULL && strlen(sess_cfg) != 0) { + pos += (size_t)snprintf( + cc_buf + pos, req_len - pos, "%s%s", + append_comma, sess_cfg); + append_comma = ","; + } + if (user_cconfig != NULL && strlen(user_cconfig) != 0) { + pos += (size_t)snprintf( + cc_buf + pos, req_len - pos, "%s%s", + append_comma, user_cconfig); + append_comma = ","; + } + if (opts->verbose > 1 && strlen(debug_cconfig) != 0) + pos += (size_t)snprintf( + cc_buf + pos, req_len - pos, "%s%s", + append_comma, debug_cconfig); + + if (strlen(cc_buf) != 0 && (ret = config_opt_name_value(wtperf, "conn_config", cc_buf)) != 0) goto err; } - if (opts->verbose > 1 || opts->index || + if ((opts->verbose > 1 && strlen(debug_tconfig) != 0) || opts->index || user_tconfig != NULL || wtperf->compress_table != NULL) { - req_len = strlen(debug_tconfig) + 20; - if (user_tconfig != NULL) - req_len += strlen(user_tconfig); - if (wtperf->compress_table != NULL) - req_len += strlen(wtperf->compress_table); - if (opts->index) - req_len += strlen(INDEX_COL_NAMES); + req_len = 20; + req_len += wtperf->compress_table != NULL ? + strlen(wtperf->compress_table) : 0; + req_len += opts->index ? strlen(INDEX_COL_NAMES) : 0; + req_len += user_tconfig != NULL ? strlen(user_tconfig) : 0; + req_len += debug_tconfig != NULL ? strlen(debug_tconfig) : 0; tc_buf = dmalloc(req_len); - snprintf(tc_buf, req_len, "%s,%s,%s,%s", - opts->index ? INDEX_COL_NAMES : "", - wtperf->compress_table != NULL ? - wtperf->compress_table : "", - opts->verbose > 1 ? debug_tconfig : "", - user_tconfig ? user_tconfig : ""); - if (strlen(tc_buf) && (ret = + + pos = 0; + append_comma = ""; + if (wtperf->compress_table != NULL && + strlen(wtperf->compress_table) != 0) { + pos += (size_t)snprintf( + tc_buf + pos, req_len - pos, "%s%s", + append_comma, wtperf->compress_table); + append_comma = ","; + } + if (opts->index) { + pos += (size_t)snprintf( + tc_buf + pos, req_len - pos, "%s%s", + append_comma, INDEX_COL_NAMES); + append_comma = ","; + } + if (user_tconfig != NULL && strlen(user_tconfig) != 0) { + pos += (size_t)snprintf( + tc_buf + pos, req_len - pos, "%s%s", + append_comma, user_tconfig); + append_comma = ","; + } + if (opts->verbose > 1 && strlen(debug_tconfig) != 0) + pos += (size_t)snprintf( + tc_buf + pos, req_len - pos, "%s%s", + append_comma, debug_tconfig); + + if (strlen(tc_buf) != 0 && (ret = config_opt_name_value(wtperf, "table_config", tc_buf)) != 0) goto err; } |