X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FUtils%2FStatisticAccumulator.ct;h=9e5d106de941ac9780e049a0794fb24f8487c002;hb=93d9568d448749dc187e7622b733a4a3caa319df;hp=adefd6c74e4577555ff3fc2156bf4618c9b95bd9;hpb=7a9d26ea01ae0fb7f3d2a046ae19f8ceb9c4a9b6;p=senf.git diff --git a/senf/Utils/StatisticAccumulator.ct b/senf/Utils/StatisticAccumulator.ct index adefd6c..9e5d106 100644 --- a/senf/Utils/StatisticAccumulator.ct +++ b/senf/Utils/StatisticAccumulator.ct @@ -81,10 +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 +{ + 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_; + } }