From 079b40edb0119f084d1ca70114411a890b909be6 Mon Sep 17 00:00:00 2001 From: Ivan Afanasyev Date: Wed, 3 Jan 2024 00:01:56 +0700 Subject: [PATCH] Fix division by zero for low frequency timers for CV statistics --- src/statistics.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/statistics.cc b/src/statistics.cc index 4a639fd2b9..261dcb299a 100644 --- a/src/statistics.cc +++ b/src/statistics.cc @@ -84,6 +84,8 @@ double StatisticsCV(const std::vector& v) { const auto stddev = StatisticsStdDev(v); const auto mean = StatisticsMean(v); + if (std::fpclassify(mean) == FP_ZERO) return 0.0; + return stddev / mean; }