aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAfanasyev Ivan <ivafanas@gmail.com>2024-01-03 19:40:59 +0700
committerGitHub <noreply@github.com>2024-01-03 12:40:59 +0000
commit2d2e07e3c5f93f210e77356fb83953fda03673f5 (patch)
treeff2c802742d025808692e6e99235b25f97c7d47c
parent7b52bf7346dead5ef4f29d7f98d2a26d6194252f (diff)
downloadgoogle-benchmark-2d2e07e3c5f93f210e77356fb83953fda03673f5.tar.gz
Fix division by zero for low frequency timers for CV statistics (#1724)
-rw-r--r--src/statistics.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/statistics.cc b/src/statistics.cc
index 4a639fd..261dcb2 100644
--- a/src/statistics.cc
+++ b/src/statistics.cc
@@ -84,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;
}