aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaksim Kita <maksim-kita@yandex-team.ru>2023-11-07 14:55:50 +0300
committermaksim-kita <maksim-kita@yandex-team.com>2023-11-07 15:47:48 +0300
commitaadba0438cea385184a33bed33591bb909c72975 (patch)
treeb9ab096313e71f355eca19e5e86d4baf9e92138a
parent5397b63de713d6cec157754cfa52548a71f5ccd8 (diff)
downloadydb-aadba0438cea385184a33bed33591bb909c72975.tar.gz
ClickBench benchmark utils add Median
ClickBench benchmark utils add Median Pull Request resolved: https://github.com/ydb-platform/ydb/pull/422
-rw-r--r--ydb/public/lib/ydb_cli/commands/benchmark_utils.cpp14
-rw-r--r--ydb/public/lib/ydb_cli/commands/benchmark_utils.h1
-rw-r--r--ydb/public/lib/ydb_cli/commands/click_bench.cpp14
3 files changed, 21 insertions, 8 deletions
diff --git a/ydb/public/lib/ydb_cli/commands/benchmark_utils.cpp b/ydb/public/lib/ydb_cli/commands/benchmark_utils.cpp
index a151bf236a..3421cd1480 100644
--- a/ydb/public/lib/ydb_cli/commands/benchmark_utils.cpp
+++ b/ydb/public/lib/ydb_cli/commands/benchmark_utils.cpp
@@ -11,6 +11,7 @@
#include <ydb/public/lib/yson_value/ydb_yson_value.h>
#include <vector>
+#include <algorithm>
namespace NYdb::NConsoleClient::BenchmarkUtils {
@@ -66,6 +67,17 @@ TTestInfo::TTestInfo(std::vector<TDuration>&& clientTimings, std::vector<TDurati
}
RttMean = totalDiff / static_cast<double>(ServerTimings.size());
+
+ auto serverTimingsCopy = ServerTimings;
+ auto centerElement = serverTimingsCopy.begin() + ServerTimings.size() / 2;
+ std::nth_element(serverTimingsCopy.begin(), centerElement, serverTimingsCopy.end());
+
+ if (ServerTimings.size() % 2 == 0) {
+ auto maxLessThanCenterElement = std::max_element(serverTimingsCopy.begin(), centerElement);
+ Median = (centerElement->MilliSeconds() + maxLessThanCenterElement->MilliSeconds()) / 2.0;
+ } else {
+ Median = centerElement->MilliSeconds();
+ }
}
TString FullTablePath(const TString& database, const TString& table) {
@@ -127,7 +139,7 @@ public:
if constexpr (std::is_same_v<TIterator, NTable::TScanQueryPartIterator>) {
if (streamPart.HasQueryStats()) {
ServerTiming = streamPart.GetQueryStats().GetTotalDuration();
- }
+ }
} else {
const auto& stats = streamPart.GetStats();
if (stats) {
diff --git a/ydb/public/lib/ydb_cli/commands/benchmark_utils.h b/ydb/public/lib/ydb_cli/commands/benchmark_utils.h
index 80aeb5145d..862c9eaad5 100644
--- a/ydb/public/lib/ydb_cli/commands/benchmark_utils.h
+++ b/ydb/public/lib/ydb_cli/commands/benchmark_utils.h
@@ -18,6 +18,7 @@ struct TTestInfo {
double RttMean = 0;
double Mean = 0;
+ double Median = 0;
double Std = 0;
std::vector<TDuration> ClientTimings; // timings captured by the client application. these timings include time RTT between server and the client application.
std::vector<TDuration> ServerTimings; // query timings measured by the server.
diff --git a/ydb/public/lib/ydb_cli/commands/click_bench.cpp b/ydb/public/lib/ydb_cli/commands/click_bench.cpp
index 16f3626112..51d3520dd7 100644
--- a/ydb/public/lib/ydb_cli/commands/click_bench.cpp
+++ b/ydb/public/lib/ydb_cli/commands/click_bench.cpp
@@ -220,9 +220,9 @@ bool TClickBenchCommandRun::RunBench(TConfig& config)
TStringStream report;
report << "Results for " << IterationsCount << " iterations" << Endl;
- report << "+---------+----------+---------+---------+----------+---------+---------+---------+---------+" << Endl;
- report << "| Query # | ColdTime | Min | Max | Mean | Std | RttMin | RttMax | RttAvg |" << Endl;
- report << "+---------+----------+---------+---------+----------+---------+---------+---------+---------+" << Endl;
+ report << "+---------+----------+---------+---------+----------+----------+---------+---------+---------+---------+" << Endl;
+ report << "| Query # | ColdTime | Min | Max | Mean | Median | Std | RttMin | RttMax | RttAvg |" << Endl;
+ report << "+---------+----------+---------+---------+----------+----------+---------+---------+---------+---------+" << Endl;
NJson::TJsonValue jsonReport(NJson::JSON_ARRAY);
const bool collectJsonSensors = !JsonReportFileName.empty();
@@ -302,26 +302,26 @@ bool TClickBenchCommandRun::RunBench(TConfig& config)
Y_ABORT_UNLESS(success);
auto& testInfo = inserted->second;
- report << Sprintf("| %02u | %8.3f | %7.3f | %7.3f | %8.3f | %7.3f | %7.3f | %7.3f | %7.3f |", queryN,
+ report << Sprintf("| %02u | %8.3f | %7.3f | %7.3f | %8.3f | %8.3f | %7.3f | %7.3f | %7.3f | %7.3f |", queryN,
testInfo.ColdTime.MilliSeconds() * 0.001, testInfo.Min.MilliSeconds() * 0.001, testInfo.Max.MilliSeconds() * 0.001,
- testInfo.Mean * 0.001, testInfo.Std * 0.001, testInfo.RttMin.MilliSeconds() * 0.001, testInfo.RttMax.MilliSeconds() * 0.001,
+ testInfo.Mean * 0.001, testInfo.Median * 0.001, testInfo.Std * 0.001, testInfo.RttMin.MilliSeconds() * 0.001, testInfo.RttMax.MilliSeconds() * 0.001,
testInfo.RttMean * 0.001) << Endl;
if (collectJsonSensors) {
jsonReport.AppendValue(GetSensorValue("ColdTime", testInfo.ColdTime, queryN));
jsonReport.AppendValue(GetSensorValue("Min", testInfo.Min, queryN));
jsonReport.AppendValue(GetSensorValue("Max", testInfo.Max, queryN));
jsonReport.AppendValue(GetSensorValue("Mean", testInfo.Mean, queryN));
+ jsonReport.AppendValue(GetSensorValue("Median", testInfo.Median, queryN));
jsonReport.AppendValue(GetSensorValue("Std", testInfo.Std, queryN));
jsonReport.AppendValue(GetSensorValue("DiffsCount", diffsCount, queryN));
jsonReport.AppendValue(GetSensorValue("FailsCount", failsCount, queryN));
jsonReport.AppendValue(GetSensorValue("SuccessCount", successIteration, queryN));
-
}
}
driver.Stop(true);
- report << "+---------+----------+---------+---------+----------+---------+---------+---------+---------+" << Endl;
+ report << "+---------+----------+---------+---------+----------+----------+---------+---------+---------+---------+" << Endl;
Cout << Endl << report.Str() << Endl;
Cout << "Results saved to " << OutFilePath << Endl;