aboutsummaryrefslogtreecommitdiff
path: root/zencore/stats.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-10-05 22:24:57 +0200
committerStefan Boberg <[email protected]>2021-10-05 22:24:57 +0200
commita446748bb0456207ac0d23d0d0fd80d3307a3dbe (patch)
treef95e1c6f43aaa53538b1ed221c1c32e5f6ff010e /zencore/stats.cpp
parentMerge branch 'main' of https://github.com/EpicGames/zen (diff)
downloadzen-a446748bb0456207ac0d23d0d0fd80d3307a3dbe.tar.xz
zen-a446748bb0456207ac0d23d0d0fd80d3307a3dbe.zip
stats: Mean returns zero when the count is zero
Diffstat (limited to 'zencore/stats.cpp')
-rw-r--r--zencore/stats.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/zencore/stats.cpp b/zencore/stats.cpp
index 47efba76b..6afd217e4 100644
--- a/zencore/stats.cpp
+++ b/zencore/stats.cpp
@@ -295,7 +295,14 @@ Histogram::Min() const
double
Histogram::Mean() const
{
- return double(m_Sum.load(std::memory_order_relaxed)) / m_Count;
+ if (m_Count)
+ {
+ return double(m_Sum.load(std::memory_order_relaxed)) / m_Count;
+ }
+ else
+ {
+ return 0.0;
+ }
}
uint64_t