X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FUtils%2FStatistics.cci;h=762aa0d5cdca000980f1ce06745df8a2f023b361;hb=92d091c2e5b387ca0c9930c7bc88d9b45630a845;hp=1f109dbe22c402152f6a217445d41d5147772ed5;hpb=601d1f509f5bb24df167a4dd5a20da67a0af9af8;p=senf.git diff --git a/senf/Utils/Statistics.cci b/senf/Utils/Statistics.cci index 1f109db..762aa0d 100644 --- a/senf/Utils/Statistics.cci +++ b/senf/Utils/Statistics.cci @@ -1,6 +1,6 @@ // $Id$ // -// Copyright (C) 2008 +// Copyright (C) 2008 // Fraunhofer Institute for Open Communication Systems (FOKUS) // Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund @@ -30,9 +30,9 @@ #include "Range.hh" #define prefix_ inline -///////////////////////////////cci.p/////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::StatisticsBase::Transform prefix_ senf::StatisticsBase::Transform::result_type @@ -42,31 +42,33 @@ senf::StatisticsBase::Transform::operator()(first_argument_type i) return i.second; } -/////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::StatisticsBase::OutputEntry prefix_ senf::StatisticsBase::OutputEntry::OutputEntry() - : n(), min(), avg(), max() + : n(), min(), avg(), max(), dev() { initDir(); } prefix_ senf::StatisticsBase::OutputEntry::OutputEntry(unsigned n_) - : n(n_), min(), avg(), max() + : n(n_), min(), avg(), max(), dev() { initDir(); } prefix_ senf::StatisticsBase::OutputEntry::OutputEntry(const OutputEntry& other) - : n(other.n), min(other.min), avg(other.avg), max(other.max) + : n(other.n), min(other.min), avg(other.avg), max(other.max), dev(other.dev) { initDir(); } prefix_ void senf::StatisticsBase::OutputEntry::initDir() { - dir.add("list", senf::membind(&OutputEntry::consoleList, this)) - .doc("List all known connected targets. This list might not be complete."); + namespace fty = senf::console::factory; + + dir.add("list", fty::Command(&OutputEntry::consoleList, this) + .doc("List all known connected targets. This list might not be complete.") ); } prefix_ senf::StatisticsBase::OutputEntry & @@ -76,22 +78,15 @@ senf::StatisticsBase::OutputEntry::operator=(const OutputEntry& other) min = other.min; avg = other.avg; max = other.max; + dev = other.dev; return *this; } -prefix_ void senf::StatisticsBase::OutputEntry::consoleList(std::ostream & os) -{ - for (boost::ptr_vector::iterator i (targets_.begin()); - i != targets_.end(); ++i) - if (! i->label.empty()) - os << i->label << "\n"; -} - -///////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::StatisticsBase prefix_ senf::StatisticsBase::StatisticsBase() - : min_ (0.0f), avg_ (0.0f), max_ (0.0f), maxQueueLen_ (0u) + : min_ (0.0f), avg_ (0.0f), max_ (0.0f), dev_ (0.0f), maxQueueLen_ (0u) {} prefix_ senf::StatisticsBase::~StatisticsBase() @@ -120,6 +115,12 @@ prefix_ float senf::StatisticsBase::max() return max_; } +prefix_ float senf::StatisticsBase::dev() + const +{ + return dev_; +} + prefix_ unsigned senf::StatisticsBase::rank() const { @@ -137,11 +138,11 @@ prefix_ std::string senf::StatisticsBase::path() return v_path(); } -/////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::Collector prefix_ senf::Collector::Collector(StatisticsBase * owner, unsigned rank) - : rank_ (rank), i_ (0u), accMin_ (FLT_MAX), accAvg_ (0.0f), accMax_ (-FLT_MAX), + : rank_ (rank), i_ (0u), accMin_ (FLT_MAX), accSum_ (0.0f), accSumSq_ (0.0f), accMax_ (-FLT_MAX), owner_ (owner) {} @@ -158,26 +159,38 @@ senf::Collector::output(unsigned n) return StatisticsBase::OutputProxy(this, StatisticsBase::output(n)); } -/////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::Statistics -prefix_ void senf::Statistics::operator()(float min, float avg, float max) +prefix_ void senf::Statistics::operator()(unsigned n, float min, float avg, float max, + float dev) { - enter(min, avg, max); + enter(n, min, avg, max, dev); } -prefix_ void senf::Statistics::operator()(float value) +prefix_ void senf::Statistics::operator()(float min, float avg, float max, float dev) { - enter(value, value, value); + 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); +} + + prefix_ senf::StatisticsBase::OutputProxy senf::Statistics::output(unsigned n) { return StatisticsBase::OutputProxy(this, StatisticsBase::output(n)); } -///////////////////////////////cci.e/////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// #undef prefix_