aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/restricted/google/benchmark/src/statistics.cc
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-05-24 12:52:43 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-05-24 13:00:05 +0300
commit17b724c0bfc83bc671073210ba805e7e833f29d8 (patch)
treeb671cf351fec7970a12ca91d7d98b507eaf91c86 /contrib/restricted/google/benchmark/src/statistics.cc
parentd2e0d3650d4af88fe27cbe7a6b2bc1a44f10694b (diff)
downloadydb-17b724c0bfc83bc671073210ba805e7e833f29d8.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/restricted/google/benchmark/src/statistics.cc')
-rw-r--r--contrib/restricted/google/benchmark/src/statistics.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/contrib/restricted/google/benchmark/src/statistics.cc b/contrib/restricted/google/benchmark/src/statistics.cc
index 844e926895..16b60261fd 100644
--- a/contrib/restricted/google/benchmark/src/statistics.cc
+++ b/contrib/restricted/google/benchmark/src/statistics.cc
@@ -32,7 +32,7 @@ auto StatisticsSum = [](const std::vector<double>& v) {
double StatisticsMean(const std::vector<double>& v) {
if (v.empty()) return 0.0;
- return StatisticsSum(v) * (1.0 / v.size());
+ return StatisticsSum(v) * (1.0 / static_cast<double>(v.size()));
}
double StatisticsMedian(const std::vector<double>& v) {
@@ -71,8 +71,11 @@ double StatisticsStdDev(const std::vector<double>& v) {
// Sample standard deviation is undefined for n = 1
if (v.size() == 1) return 0.0;
- const double avg_squares = SumSquares(v) * (1.0 / v.size());
- return Sqrt(v.size() / (v.size() - 1.0) * (avg_squares - Sqr(mean)));
+ const double avg_squares =
+ SumSquares(v) * (1.0 / static_cast<double>(v.size()));
+ return Sqrt(static_cast<double>(v.size()) /
+ (static_cast<double>(v.size()) - 1.0) *
+ (avg_squares - Sqr(mean)));
}
double StatisticsCV(const std::vector<double>& v) {
@@ -81,6 +84,8 @@ double StatisticsCV(const std::vector<double>& v) {
const auto stddev = StatisticsStdDev(v);
const auto mean = StatisticsMean(v);
+ if (std::fpclassify(mean) == FP_ZERO) return 0.0;
+
return stddev / mean;
}
@@ -92,7 +97,7 @@ std::vector<BenchmarkReporter::Run> ComputeStats(
auto error_count = std::count_if(reports.begin(), reports.end(),
[](Run const& run) { return run.skipped; });
- if (reports.size() - error_count < 2) {
+ if (reports.size() - static_cast<size_t>(error_count) < 2) {
// We don't report aggregated data if there was a single run.
return results;
}
@@ -174,7 +179,7 @@ std::vector<BenchmarkReporter::Run> ComputeStats(
// Similarly, if there are N repetitions with 1 iterations each,
// an aggregate will be computed over N measurements, not 1.
// Thus it is best to simply use the count of separate reports.
- data.iterations = reports.size();
+ data.iterations = static_cast<IterationCount>(reports.size());
data.real_accumulated_time = Stat.compute_(real_accumulated_time_stat);
data.cpu_accumulated_time = Stat.compute_(cpu_accumulated_time_stat);