diff options
author | ivanmorozov <ivanmorozov@yandex-team.com> | 2023-06-22 12:29:50 +0300 |
---|---|---|
committer | ivanmorozov <ivanmorozov@yandex-team.com> | 2023-06-22 12:29:50 +0300 |
commit | e59622c6ed8a1d77a3b38f6896fb2ed4eb1c2afb (patch) | |
tree | d845f9f253c804a6f559bdf0a0c0d3766568929e | |
parent | cd3bc4dfb33095ad45720b6382c948d5a0f99bf9 (diff) | |
download | ydb-e59622c6ed8a1d77a3b38f6896fb2ed4eb1c2afb.tar.gz |
correct sigma calculation for special case with 1 element
-rw-r--r-- | ydb/public/lib/ydb_cli/commands/benchmark_utils.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/ydb/public/lib/ydb_cli/commands/benchmark_utils.cpp b/ydb/public/lib/ydb_cli/commands/benchmark_utils.cpp index f9a3fb0bd2..f66e413667 100644 --- a/ydb/public/lib/ydb_cli/commands/benchmark_utils.cpp +++ b/ydb/public/lib/ydb_cli/commands/benchmark_utils.cpp @@ -30,7 +30,7 @@ TTestInfo::TTestInfo(std::vector<TDuration>&& clientTimings, std::vector<TDurati ColdTime = ServerTimings[0]; - if (ServerTimings.size() >= 1) { + { ui32 sum = 0; for (const auto& timing : ServerTimings) { if (Max < timing) { @@ -43,15 +43,13 @@ TTestInfo::TTestInfo(std::vector<TDuration>&& clientTimings, std::vector<TDurati } Mean = static_cast<double>(sum) / static_cast<double>(ServerTimings.size()); - if (ServerTimings.size() > 1) { - double variance = 0; - for (const auto& timing : ServerTimings) { - double diff = (Mean - timing.MilliSeconds()); - variance += diff * diff; - } - variance = variance / static_cast<double>(ServerTimings.size() - 1); - Std = sqrt(variance); + double variance = 0; + for (const auto& timing : ServerTimings) { + double diff = (Mean - timing.MilliSeconds()); + variance += diff * diff; } + variance = variance / static_cast<double>(ServerTimings.size()); + Std = sqrt(variance); } double totalDiff = 0; |