diff --git a/src/c++/perf_analyzer/command_line_parser.cc b/src/c++/perf_analyzer/command_line_parser.cc index 88cf441d7..8003be711 100644 --- a/src/c++/perf_analyzer/command_line_parser.cc +++ b/src/c++/perf_analyzer/command_line_parser.cc @@ -1715,9 +1715,8 @@ CLParser::ParseCommandLine(int argc, char** argv) // Overriding the max_threads default for request_rate search if (!params_->max_threads_specified && params_->targeting_concurrency()) { - params_->max_threads = 16; params_->max_threads = - std::max(params_->max_threads, params_->concurrency_range.end); + std::max(DEFAULT_MAX_THREADS, params_->concurrency_range.end); } if (params_->using_custom_intervals) { diff --git a/src/c++/perf_analyzer/constants.h b/src/c++/perf_analyzer/constants.h index 443806781..fbcd911b8 100644 --- a/src/c++/perf_analyzer/constants.h +++ b/src/c++/perf_analyzer/constants.h @@ -41,6 +41,7 @@ constexpr static const uint32_t STABILITY_ERROR = 2; constexpr static const uint32_t OPTION_ERROR = 3; constexpr static const uint32_t GENERIC_ERROR = 99; +constexpr static const size_t DEFAULT_MAX_THREADS = 16; const double DELAY_PCT_THRESHOLD{1.0}; diff --git a/src/c++/perf_analyzer/test_command_line_parser.cc b/src/c++/perf_analyzer/test_command_line_parser.cc index 42c5a4644..ac70ba9dd 100644 --- a/src/c++/perf_analyzer/test_command_line_parser.cc +++ b/src/c++/perf_analyzer/test_command_line_parser.cc @@ -371,12 +371,11 @@ class TestCLParser : public CLParser { void CheckValidRange( std::vector& args, char* option_name, TestCLParser& parser, - PAParamsPtr& act, bool& using_range, Range& range, - PAParamsPtr& exp) + PAParamsPtr& act, bool& using_range, Range& range, size_t* max_threads) { SUBCASE("start:end provided") { - exp->max_threads = 400; + *max_threads = 400; args.push_back(option_name); args.push_back("100:400"); // start:end @@ -394,7 +393,7 @@ CheckValidRange( SUBCASE("start:end:step provided") { - exp->max_threads = 400; + *max_threads = 400; args.push_back(option_name); args.push_back("100:400:10"); // start:end:step @@ -1134,7 +1133,7 @@ TEST_CASE("Testing Command Line Parser") CheckValidRange( args, option_name, parser, act, exp->using_concurrency_range, - exp->concurrency_range, exp); + exp->concurrency_range, &(exp->max_threads)); CheckInvalidRange(args, option_name, parser, act, check_params); SUBCASE("wrong separator") @@ -1177,7 +1176,7 @@ TEST_CASE("Testing Command Line Parser") check_params = false; } - SUBCASE("concurrency-range.end < 16") + SUBCASE("Max threads set to default when concurrency-range < 16") { args.push_back(option_name); args.push_back("10:10"); // start @@ -1195,7 +1194,7 @@ TEST_CASE("Testing Command Line Parser") exp->max_threads = 16; } - SUBCASE("concurrency-range.end == 16") + SUBCASE("Max_threads set to default when concurrency-range.end = 16") { args.push_back(option_name); args.push_back("10:16"); // start @@ -1213,7 +1212,7 @@ TEST_CASE("Testing Command Line Parser") exp->max_threads = 16; } - SUBCASE("concurrency-range.end > 16") + SUBCASE("Max_threads set to concurrency-range.end when concurrency-range.end > 16") { args.push_back(option_name); args.push_back("10:40"); // start @@ -1267,7 +1266,7 @@ TEST_CASE("Testing Command Line Parser") CheckValidRange( args, option_name, parser, act, exp->is_using_periodic_concurrency_mode, - exp->periodic_concurrency_range, exp); + exp->periodic_concurrency_range, &(exp->max_threads)); CheckInvalidRange(args, option_name, parser, act, check_params);