diff --git a/dbms/programs/performance-test/PerformanceTest.cpp b/dbms/programs/performance-test/PerformanceTest.cpp index 7d0e180d536..eb8d0ccbfda 100644 --- a/dbms/programs/performance-test/PerformanceTest.cpp +++ b/dbms/programs/performance-test/PerformanceTest.cpp @@ -128,6 +128,32 @@ UInt64 PerformanceTest::calculateMaxExecTime() const return result; } + +void PerformanceTest::prepare() const +{ + for (const auto & query : test_info.create_queries) + { + LOG_INFO(log, "Executing create query '" << query << "'"); + connection.sendQuery(query); + } + + for (const auto & query : test_info.fill_queries) + { + LOG_INFO(log, "Executing fill query '" << query << "'"); + connection.sendQuery(query); + } + +} + +void PerformanceTest::finish() const +{ + for (const auto & query : test_info.drop_queries) + { + LOG_INFO(log, "Executing drop query '" << query << "'"); + connection.sendQuery(query); + } +} + std::vector PerformanceTest::execute() { std::vector statistics_by_run; diff --git a/dbms/programs/performance-test/PerformanceTest.h b/dbms/programs/performance-test/PerformanceTest.h index 130d4fca6a5..107c1bb6963 100644 --- a/dbms/programs/performance-test/PerformanceTest.h +++ b/dbms/programs/performance-test/PerformanceTest.h @@ -25,12 +25,15 @@ public: Context & context_); bool checkPreconditions() const; + void prepare() const; std::vector execute(); + void finish() const; const PerformanceTestInfo & getTestInfo() const { return test_info; } + bool checkSIGINT() const { return got_SIGINT; diff --git a/dbms/programs/performance-test/PerformanceTestInfo.cpp b/dbms/programs/performance-test/PerformanceTestInfo.cpp index 3fea7456430..e10fd1e915f 100644 --- a/dbms/programs/performance-test/PerformanceTestInfo.cpp +++ b/dbms/programs/performance-test/PerformanceTestInfo.cpp @@ -90,6 +90,7 @@ PerformanceTestInfo::PerformanceTestInfo( getExecutionType(config); getStopConditions(config); getMetrics(config); + extractAuxiliaryQueries(config); } void PerformanceTestInfo::applySettings(XMLConfigurationPtr config) @@ -269,4 +270,16 @@ void PerformanceTestInfo::getMetrics(XMLConfigurationPtr config) checkMetricsInput(metrics, exec_type); } +void PerformanceTestInfo::extractAuxiliaryQueries(XMLConfigurationPtr config) +{ + if (config->has("create_query")) + create_queries = getMultipleValuesFromConfig(*config, "", "create_query"); + + if (config->has("fill_query")) + fill_queries = getMultipleValuesFromConfig(*config, "", "fill_query"); + + if (config->has("drop_query")) + drop_queries = getMultipleValuesFromConfig(*config, "", "drop_query"); +} + } diff --git a/dbms/programs/performance-test/PerformanceTestInfo.h b/dbms/programs/performance-test/PerformanceTestInfo.h index 041cd680c8b..9b84a885de0 100644 --- a/dbms/programs/performance-test/PerformanceTestInfo.h +++ b/dbms/programs/performance-test/PerformanceTestInfo.h @@ -43,6 +43,10 @@ public: std::string profiles_file; std::vector stop_conditions_by_run; + Strings create_queries; + Strings fill_queries; + Strings drop_queries; + private: void applySettings(XMLConfigurationPtr config); void extractQueries(XMLConfigurationPtr config); @@ -50,6 +54,7 @@ private: void getExecutionType(XMLConfigurationPtr config); void getStopConditions(XMLConfigurationPtr config); void getMetrics(XMLConfigurationPtr config); + void extractAuxiliaryQueries(XMLConfigurationPtr config); }; } diff --git a/dbms/programs/performance-test/PerformanceTestSuite.cpp b/dbms/programs/performance-test/PerformanceTestSuite.cpp index 290335ca31f..d26d182fc2a 100644 --- a/dbms/programs/performance-test/PerformanceTestSuite.cpp +++ b/dbms/programs/performance-test/PerformanceTestSuite.cpp @@ -202,11 +202,18 @@ private: current.checkPreconditions(); LOG_INFO(log, "Preconditions for test '" << info.test_name << "' are fullfilled"); - + LOG_INFO(log, "Preparing for run, have " << info.create_queries.size() + << " create queries and " << info.fill_queries.size() << " fill queries"); + current.prepare(); + LOG_INFO(log, "Prepared"); LOG_INFO(log, "Running test '" << info.test_name << "'"); auto result = current.execute(); LOG_INFO(log, "Test '" << info.test_name << "' finished"); + LOG_INFO(log, "Running post run queries"); + current.finish(); + LOG_INFO(log, "Postqueries finished"); + if (lite_output) return {report_builder->buildCompactReport(info, result), current.checkSIGINT()}; else diff --git a/dbms/tests/performance/trim/trim_whitespace.xml b/dbms/tests/performance/trim/trim_whitespace.xml index d7fc5d967a6..41449318f85 100644 --- a/dbms/tests/performance/trim/trim_whitespace.xml +++ b/dbms/tests/performance/trim/trim_whitespace.xml @@ -2,9 +2,10 @@ trim_whitespaces loop - - whitespaces - + CREATE TABLE IF NOT EXISTS whitespaces(value String) ENGINE = MergeTree() PARTITION BY tuple() ORDER BY tuple() + INSERT INTO whitespaces SELECT value FROM (SELECT arrayStringConcat(groupArray(' ')) AS spaces, concat(spaces, toString(any(number)), spaces) AS value FROM numbers(100000000) GROUP BY pow(number, intHash32(number) % 4) % 12345678) + INSERT INTO whitespaces SELECT value FROM (SELECT arrayStringConcat(groupArray(' ')) AS spaces, concat(spaces, toString(any(number)), spaces) AS value FROM numbers(100000000) GROUP BY pow(number, intHash32(number) % 4) % 12345678) + INSERT INTO whitespaces SELECT value FROM (SELECT arrayStringConcat(groupArray(' ')) AS spaces, concat(spaces, toString(any(number)), spaces) AS value FROM numbers(100000000) GROUP BY pow(number, intHash32(number) % 4) % 12345678) @@ -32,4 +33,6 @@ SELECT count() FROM whitespaces WHERE NOT ignore({func}) + + DROP TABLE IF EXISTS whitespaces diff --git a/dbms/tests/performance/trim/whitespaces.sql b/dbms/tests/performance/trim/whitespaces.sql deleted file mode 100644 index 653bd2e7a5a..00000000000 --- a/dbms/tests/performance/trim/whitespaces.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE whitespaces -( - value String -) -ENGINE = MergeTree() -PARTITION BY tuple() -ORDER BY tuple() - -INSERT INTO whitespaces SELECT value -FROM -( - SELECT - arrayStringConcat(groupArray(' ')) AS spaces, - concat(spaces, toString(any(number)), spaces) AS value - FROM numbers(100000000) - GROUP BY pow(number, intHash32(number) % 4) % 12345678 -) -- repeat something like this multiple times and/or just copy whitespaces table into itself