From: mtk Date: Wed, 19 Jan 2011 14:11:37 +0000 (+0000) Subject: do not reset the last_avg() if no new values have been reported in the current period X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=f29f8e3fa5f1c0df091520da92f50b623543490f;p=senf.git do not reset the last_avg() if no new values have been reported in the current period git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1767 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Utils/StatisticAccumulator.ct b/senf/Utils/StatisticAccumulator.ct index 0117732..9e5d106 100644 --- a/senf/Utils/StatisticAccumulator.ct +++ b/senf/Utils/StatisticAccumulator.ct @@ -81,20 +81,29 @@ prefix_ void senf::StatisticAccumulator::accumulate( T value) template prefix_ void senf::StatisticAccumulator::clear() { - last_avg_ = avg(); - count_ = 0; - sum_squared_ = 0; - sum_ = min_ = max_ = 0; + if( count_ > 0){ + last_avg_ = avg(); + count_ = 0; + sum_squared_ = 0; + sum_ = min_ = max_ = 0; + } } template prefix_ void senf::StatisticAccumulator::data( StatisticsData &data_) const { - data_.min = (float) min_; - data_.avg = avg(); - data_.max = (float) max_; - data_.stddev = stddev(); - data_.count = count_; + if( count_ == 0){ + data_.min = data_.avg = data_.max = last_avg_; + data_.stddev = 0.0; + data_.count = 0; + } + else{ + data_.min = (float) min_; + data_.avg = avg(); + data_.max = (float) max_; + data_.stddev = stddev(); + data_.count = count_; + } }