diff --git a/dbms/src/Client/PerformanceTest.cpp b/dbms/src/Client/PerformanceTest.cpp index ec0d1096071..acbcae0f176 100644 --- a/dbms/src/Client/PerformanceTest.cpp +++ b/dbms/src/Client/PerformanceTest.cpp @@ -585,6 +585,7 @@ public: const String & default_database_, const String & user_, const String & password_, + const bool & lite_output_, const std::vector & input_files, const std::vector & tags, const std::vector & without_tags, @@ -594,7 +595,8 @@ public: const std::vector & without_names_regexp) : connection(host_, port_, default_database_, user_, password_), testsConfigurations(input_files.size()), - gotSIGINT(false) + gotSIGINT(false), + lite_output(lite_output_) { if (input_files.size() < 1) { @@ -639,6 +641,7 @@ private: bool gotSIGINT; std::vector stopCriterions; std::string main_metric; + bool lite_output; // TODO: create enum class instead of string #define incFulfilledCriterions(index, CRITERION) \ @@ -788,13 +791,18 @@ private: AbstractConfig metricsView(testConfig->createView("metrics")); Keys metrics; metricsView->keys(metrics); + main_metric = testConfig->getString("main_metric", ""); - if (std::find(metrics.begin(), metrics.end(), "main_metric") != metrics.end()) - { - main_metric = metricsView->getString("main_metric"); - metrics.erase( std::remove(metrics.begin(), metrics.end(), "main_metric"), metrics.end() ); + if (!main_metric.empty()) { + if (std::find(metrics.begin(), metrics.end(), main_metric) == metrics.end()) + metrics.push_back(main_metric); + } else { + if (lite_output) + throw Poco::Exception("Specify main_metric for lite output", 1); } - checkMetricInput(metrics); + + if (metrics.size() > 0) + checkMetricsInput(metrics); statistics.resize(timesToRun * queries.size()); for (size_t numberOfLaunch = 0; numberOfLaunch < timesToRun; ++numberOfLaunch) @@ -818,13 +826,13 @@ private: runQueries(queriesWithIndexes); } - if (metrics.size() == 1) - minOutput(metrics[0]); + if (lite_output) + minOutput(main_metric); else constructTotalInfo(); } - void checkMetricInput(const Strings & metrics) const + void checkMetricsInput(const Strings & metrics) const { std::vector loopMetrics = {"min_time", "quantiles", "total_time", "queries_per_second", "rows_per_second", "bytes_per_second"}; @@ -1103,6 +1111,7 @@ public: jsonOutput["hostname"].set(hostname); jsonOutput["Number of CPUs"].set(sysconf(_SC_NPROCESSORS_ONLN)); jsonOutput["test_name"].set(testName); + jsonOutput["main_metric"].set(main_metric); if (substitutions.size()) { @@ -1228,6 +1237,7 @@ int mainEntryClickhousePerformanceTest(int argc, char ** argv) boost::program_options::options_description desc("Allowed options"); desc.add_options() ("help", "produce help message") + ("lite", "use lite version of output") ("host,h", value()->default_value("localhost"), "") ("port", value()->default_value(9000), "") ("user", value()->default_value("default"), "") @@ -1260,7 +1270,7 @@ int mainEntryClickhousePerformanceTest(int argc, char ** argv) { std::cout << "Usage: " << argv[0] << " [options] [test_file ...] [tests_folder]\n"; std::cout << desc << "\n"; - return 1; + return 0; } if (!options.count("input-files")) @@ -1313,6 +1323,7 @@ int mainEntryClickhousePerformanceTest(int argc, char ** argv) options["database"].as(), options["user"].as(), options["password"].as(), + options.count("lite") > 0, options["input-files"].as(), tests_tags, skip_tags,