mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
Enable all metrics in performance test by default
This commit is contained in:
parent
1f95bf18e4
commit
321caa7f5c
@ -36,42 +36,6 @@ void extractSettings(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkMetricsInput(const Strings & metrics, ExecutionType exec_type)
|
|
||||||
{
|
|
||||||
Strings loop_metrics = {
|
|
||||||
"min_time", "quantiles", "total_time",
|
|
||||||
"queries_per_second", "rows_per_second",
|
|
||||||
"bytes_per_second"};
|
|
||||||
|
|
||||||
Strings non_loop_metrics = {
|
|
||||||
"max_rows_per_second", "max_bytes_per_second",
|
|
||||||
"avg_rows_per_second", "avg_bytes_per_second"};
|
|
||||||
|
|
||||||
if (exec_type == ExecutionType::Loop)
|
|
||||||
{
|
|
||||||
for (const std::string & metric : metrics)
|
|
||||||
{
|
|
||||||
auto non_loop_pos =
|
|
||||||
std::find(non_loop_metrics.begin(), non_loop_metrics.end(), metric);
|
|
||||||
|
|
||||||
if (non_loop_pos != non_loop_metrics.end())
|
|
||||||
throw Exception("Wrong type of metric for loop execution type (" + metric + ")",
|
|
||||||
ErrorCodes::BAD_ARGUMENTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (const std::string & metric : metrics)
|
|
||||||
{
|
|
||||||
auto loop_pos = std::find(loop_metrics.begin(), loop_metrics.end(), metric);
|
|
||||||
if (loop_pos != loop_metrics.end())
|
|
||||||
throw Exception(
|
|
||||||
"Wrong type of metric for non-loop execution type (" + metric + ")",
|
|
||||||
ErrorCodes::BAD_ARGUMENTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -84,12 +48,19 @@ PerformanceTestInfo::PerformanceTestInfo(
|
|||||||
{
|
{
|
||||||
test_name = config->getString("name");
|
test_name = config->getString("name");
|
||||||
path = config->getString("path");
|
path = config->getString("path");
|
||||||
|
if (config->has("main_metric"))
|
||||||
|
{
|
||||||
|
Strings main_metrics;
|
||||||
|
config->keys("main_metric", main_metrics);
|
||||||
|
if (main_metrics.size())
|
||||||
|
main_metric = main_metrics[0];
|
||||||
|
}
|
||||||
|
|
||||||
applySettings(config);
|
applySettings(config);
|
||||||
extractQueries(config);
|
extractQueries(config);
|
||||||
processSubstitutions(config);
|
processSubstitutions(config);
|
||||||
getExecutionType(config);
|
getExecutionType(config);
|
||||||
getStopConditions(config);
|
getStopConditions(config);
|
||||||
getMetrics(config);
|
|
||||||
extractAuxiliaryQueries(config);
|
extractAuxiliaryQueries(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,37 +210,6 @@ void PerformanceTestInfo::getStopConditions(XMLConfigurationPtr config)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PerformanceTestInfo::getMetrics(XMLConfigurationPtr config)
|
|
||||||
{
|
|
||||||
ConfigurationPtr metrics_view(config->createView("metrics"));
|
|
||||||
metrics_view->keys(metrics);
|
|
||||||
|
|
||||||
if (config->has("main_metric"))
|
|
||||||
{
|
|
||||||
Strings main_metrics;
|
|
||||||
config->keys("main_metric", main_metrics);
|
|
||||||
if (main_metrics.size())
|
|
||||||
main_metric = main_metrics[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!main_metric.empty())
|
|
||||||
{
|
|
||||||
if (std::find(metrics.begin(), metrics.end(), main_metric) == metrics.end())
|
|
||||||
metrics.push_back(main_metric);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (metrics.empty())
|
|
||||||
throw Exception("You shoud specify at least one metric",
|
|
||||||
ErrorCodes::BAD_ARGUMENTS);
|
|
||||||
main_metric = metrics[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (metrics.size() > 0)
|
|
||||||
checkMetricsInput(metrics, exec_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PerformanceTestInfo::extractAuxiliaryQueries(XMLConfigurationPtr config)
|
void PerformanceTestInfo::extractAuxiliaryQueries(XMLConfigurationPtr config)
|
||||||
{
|
{
|
||||||
if (config->has("create_query"))
|
if (config->has("create_query"))
|
||||||
|
@ -33,7 +33,6 @@ public:
|
|||||||
std::string main_metric;
|
std::string main_metric;
|
||||||
|
|
||||||
Strings queries;
|
Strings queries;
|
||||||
Strings metrics;
|
|
||||||
|
|
||||||
Settings settings;
|
Settings settings;
|
||||||
ExecutionType exec_type;
|
ExecutionType exec_type;
|
||||||
|
@ -17,6 +17,18 @@ namespace DB
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const std::regex QUOTE_REGEX{"\""};
|
const std::regex QUOTE_REGEX{"\""};
|
||||||
|
std::string getMainMetric(const PerformanceTestInfo & test_info)
|
||||||
|
{
|
||||||
|
std::string main_metric;
|
||||||
|
if (test_info.main_metric.empty())
|
||||||
|
if (test_info.exec_type == ExecutionType::Loop)
|
||||||
|
main_metric = "min_time";
|
||||||
|
else
|
||||||
|
main_metric = "rows_per_second";
|
||||||
|
else
|
||||||
|
main_metric = test_info.main_metric;
|
||||||
|
return main_metric;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReportBuilder::ReportBuilder(const std::string & server_version_)
|
ReportBuilder::ReportBuilder(const std::string & server_version_)
|
||||||
@ -48,13 +60,7 @@ std::string ReportBuilder::buildFullReport(
|
|||||||
json_output.set("time", getCurrentTime());
|
json_output.set("time", getCurrentTime());
|
||||||
json_output.set("test_name", test_info.test_name);
|
json_output.set("test_name", test_info.test_name);
|
||||||
json_output.set("path", test_info.path);
|
json_output.set("path", test_info.path);
|
||||||
json_output.set("main_metric", test_info.main_metric);
|
json_output.set("main_metric", getMainMetric(test_info));
|
||||||
|
|
||||||
auto has_metric = [&test_info] (const std::string & metric_name)
|
|
||||||
{
|
|
||||||
return std::find(test_info.metrics.begin(),
|
|
||||||
test_info.metrics.end(), metric_name) != test_info.metrics.end();
|
|
||||||
};
|
|
||||||
|
|
||||||
if (test_info.substitutions.size())
|
if (test_info.substitutions.size())
|
||||||
{
|
{
|
||||||
@ -108,61 +114,46 @@ std::string ReportBuilder::buildFullReport(
|
|||||||
if (test_info.exec_type == ExecutionType::Loop)
|
if (test_info.exec_type == ExecutionType::Loop)
|
||||||
{
|
{
|
||||||
/// in seconds
|
/// in seconds
|
||||||
if (has_metric("min_time"))
|
runJSON.set("min_time", statistics.min_time / double(1000));
|
||||||
runJSON.set("min_time", statistics.min_time / double(1000));
|
|
||||||
|
|
||||||
if (has_metric("quantiles"))
|
JSONString quantiles(4); /// here, 4 is the size of \t padding
|
||||||
|
for (double percent = 10; percent <= 90; percent += 10)
|
||||||
{
|
{
|
||||||
JSONString quantiles(4); /// here, 4 is the size of \t padding
|
std::string quantile_key = std::to_string(percent / 100.0);
|
||||||
for (double percent = 10; percent <= 90; percent += 10)
|
while (quantile_key.back() == '0')
|
||||||
{
|
quantile_key.pop_back();
|
||||||
std::string quantile_key = std::to_string(percent / 100.0);
|
|
||||||
while (quantile_key.back() == '0')
|
|
||||||
quantile_key.pop_back();
|
|
||||||
|
|
||||||
quantiles.set(quantile_key,
|
quantiles.set(quantile_key,
|
||||||
statistics.sampler.quantileInterpolated(percent / 100.0));
|
statistics.sampler.quantileInterpolated(percent / 100.0));
|
||||||
}
|
|
||||||
quantiles.set("0.95",
|
|
||||||
statistics.sampler.quantileInterpolated(95 / 100.0));
|
|
||||||
quantiles.set("0.99",
|
|
||||||
statistics.sampler.quantileInterpolated(99 / 100.0));
|
|
||||||
quantiles.set("0.999",
|
|
||||||
statistics.sampler.quantileInterpolated(99.9 / 100.0));
|
|
||||||
quantiles.set("0.9999",
|
|
||||||
statistics.sampler.quantileInterpolated(99.99 / 100.0));
|
|
||||||
|
|
||||||
runJSON.set("quantiles", quantiles.asString());
|
|
||||||
}
|
}
|
||||||
|
quantiles.set("0.95",
|
||||||
|
statistics.sampler.quantileInterpolated(95 / 100.0));
|
||||||
|
quantiles.set("0.99",
|
||||||
|
statistics.sampler.quantileInterpolated(99 / 100.0));
|
||||||
|
quantiles.set("0.999",
|
||||||
|
statistics.sampler.quantileInterpolated(99.9 / 100.0));
|
||||||
|
quantiles.set("0.9999",
|
||||||
|
statistics.sampler.quantileInterpolated(99.99 / 100.0));
|
||||||
|
|
||||||
if (has_metric("total_time"))
|
runJSON.set("quantiles", quantiles.asString());
|
||||||
runJSON.set("total_time", statistics.total_time);
|
|
||||||
|
|
||||||
if (has_metric("queries_per_second"))
|
runJSON.set("total_time", statistics.total_time);
|
||||||
runJSON.set("queries_per_second",
|
|
||||||
double(statistics.queries) / statistics.total_time);
|
|
||||||
|
|
||||||
if (has_metric("rows_per_second"))
|
runJSON.set("queries_per_second",
|
||||||
runJSON.set("rows_per_second",
|
static_cast<double>(statistics.queries) / statistics.total_time);
|
||||||
double(statistics.total_rows_read) / statistics.total_time);
|
|
||||||
|
|
||||||
if (has_metric("bytes_per_second"))
|
runJSON.set("rows_per_second",
|
||||||
runJSON.set("bytes_per_second",
|
static_cast<double>(statistics.total_rows_read) / statistics.total_time);
|
||||||
double(statistics.total_bytes_read) / statistics.total_time);
|
|
||||||
|
runJSON.set("bytes_per_second",
|
||||||
|
static_cast<double>(statistics.total_bytes_read) / statistics.total_time);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (has_metric("max_rows_per_second"))
|
runJSON.set("max_rows_per_second", statistics.max_rows_speed);
|
||||||
runJSON.set("max_rows_per_second", statistics.max_rows_speed);
|
runJSON.set("max_bytes_per_second", statistics.max_bytes_speed);
|
||||||
|
runJSON.set("avg_rows_per_second", statistics.avg_rows_speed_value);
|
||||||
if (has_metric("max_bytes_per_second"))
|
runJSON.set("avg_bytes_per_second", statistics.avg_bytes_speed_value);
|
||||||
runJSON.set("max_bytes_per_second", statistics.max_bytes_speed);
|
|
||||||
|
|
||||||
if (has_metric("avg_rows_per_second"))
|
|
||||||
runJSON.set("avg_rows_per_second", statistics.avg_rows_speed_value);
|
|
||||||
|
|
||||||
if (has_metric("avg_bytes_per_second"))
|
|
||||||
runJSON.set("avg_bytes_per_second", statistics.avg_bytes_speed_value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run_infos.push_back(runJSON);
|
run_infos.push_back(runJSON);
|
||||||
@ -193,9 +184,12 @@ std::string ReportBuilder::buildCompactReport(
|
|||||||
output << "query \"" << test_info.queries[query_index] << "\", ";
|
output << "query \"" << test_info.queries[query_index] << "\", ";
|
||||||
|
|
||||||
output << "run " << std::to_string(number_of_launch + 1) << ": ";
|
output << "run " << std::to_string(number_of_launch + 1) << ": ";
|
||||||
output << test_info.main_metric << " = ";
|
|
||||||
|
std::string main_metric = getMainMetric(test_info);
|
||||||
|
|
||||||
|
output << main_metric << " = ";
|
||||||
size_t index = number_of_launch * test_info.queries.size() + query_index;
|
size_t index = number_of_launch * test_info.queries.size() + query_index;
|
||||||
output << stats[index].getStatisticByName(test_info.main_metric);
|
output << stats[index].getStatisticByName(main_metric);
|
||||||
output << "\n";
|
output << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user