From: mtk Date: Tue, 11 Jan 2011 20:40:35 +0000 (+0000) Subject: introduced a StatisticsData Object to hold the aggregated stats data provided by... X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=be253d22a60afc49fa9265fcff4728742e9f9a2d;p=senf.git introduced a StatisticsData Object to hold the aggregated stats data provided by the accumulator git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1761 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Utils/StatisticAccumulator.ct b/senf/Utils/StatisticAccumulator.ct index adefd6c..e2c7497 100644 --- a/senf/Utils/StatisticAccumulator.ct +++ b/senf/Utils/StatisticAccumulator.ct @@ -87,6 +87,16 @@ prefix_ void senf::StatisticAccumulator::clear() 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; +} + ///////////////////////////////ct.e//////////////////////////////////////// #undef prefix_ diff --git a/senf/Utils/StatisticAccumulator.hh b/senf/Utils/StatisticAccumulator.hh index 388ef99..8bd2b32 100644 --- a/senf/Utils/StatisticAccumulator.hh +++ b/senf/Utils/StatisticAccumulator.hh @@ -46,6 +46,14 @@ namespace senf { \ingroup senf_statistics */ + struct StatisticsData{ + float min; + float max; + float avg; + float stddev; + boost::uint32_t count; + }; + template class StatisticAccumulator { @@ -80,6 +88,9 @@ namespace senf { boost::uint32_t count() const; ///< Returns count of accumulated values. /**< This method returns count of accumulated values of the current accumulation.*/ + void data( StatisticsData & data_) const; + ///< Returns the accumulated data as a tuple + /**< This method returns the accumulated information as a tuple.*/ private: T sum_squared_; @@ -96,7 +107,6 @@ namespace senf { typedef StatisticAccumulator StatisticAccumulatorInt; typedef StatisticAccumulator StatisticAccumulatorFloat; - } ///////////////////////////////hh.e//////////////////////////////////////// //#include "StatisticAccumulator.cci" diff --git a/senf/Utils/Statistics.cci b/senf/Utils/Statistics.cci index d522f9f..a9e51eb 100644 --- a/senf/Utils/Statistics.cci +++ b/senf/Utils/Statistics.cci @@ -181,6 +181,11 @@ prefix_ void senf::Statistics::operator()(float min, float avg, float max, float enter(1, min, avg, max, dev); } +prefix_ void senf::Statistics::operator()(StatisticsData const & data) +{ + enter(1, data.min, data.avg, data.max, data.stddev); +} + prefix_ void senf::Statistics::operator()(float value, float dev) { enter(1, value, value, value, dev); diff --git a/senf/Utils/Statistics.hh b/senf/Utils/Statistics.hh index 3093b1c..41ead1a 100644 --- a/senf/Utils/Statistics.hh +++ b/senf/Utils/Statistics.hh @@ -465,6 +465,10 @@ namespace senf { ///< Same as operator() with \a min == \a avg == \a max /**< Provided so a Statistics instance can be directly used as a signal target. */ + void operator()(StatisticsData const & data); + ///< Same as operator(), but imports statistics data from a StatisticsData object + /**< Provided so a Statistics instance can be directly used + as a signal target. */ template void operator()(unsigned n, StatisticAccumulator & sa); ///< Same as operator() gathers values from StatisticAccumulator