Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Statistics.cci

Go to the documentation of this file.
00001 // $Id: Statistics.cci 1781 2011-04-11 12:10:19Z tho $
00002 //
00003 // Copyright (C) 2008
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 //#include "Statistics.ih"
00027 
00028 // Custom includes
00029 #include <float.h>
00030 #include <senf/Utils/Console/ParsedCommand.hh>
00031 #include "Range.hh"
00032 
00033 #define prefix_ inline
00034 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00035 
00036 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00037 // senf::StatisticsBase::Transform
00038 
00039 prefix_ senf::StatisticsBase::Transform::result_type
00040 senf::StatisticsBase::Transform::operator()(first_argument_type i)
00041     const
00042 {
00043     return i.second;
00044 }
00045 
00046 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00047 // senf::StatisticsBase::OutputEntry
00048 
00049 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry()
00050     : n(), min(), avg(), max(), dev()
00051 {
00052     initDir();
00053 }
00054 
00055 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry(unsigned n_)
00056     : n(n_), min(), avg(), max(), dev()
00057 {
00058     initDir();
00059 }
00060 
00061 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry(const OutputEntry& other)
00062     : n(other.n), min(other.min), avg(other.avg), max(other.max), dev(other.dev)
00063 {
00064     initDir();
00065 }
00066 
00067 prefix_ void senf::StatisticsBase::OutputEntry::initDir()
00068 {
00069     dir.add("list", console::factory::Command(&OutputEntry::consoleList, this)
00070             .doc("List all known connected targets. This list might not be complete.") );
00071 }
00072 
00073 prefix_ senf::StatisticsBase::OutputEntry &
00074 senf::StatisticsBase::OutputEntry::operator=(const OutputEntry& other)
00075 {
00076     n = other.n;
00077     min = other.min;
00078     avg = other.avg;
00079     max = other.max;
00080     dev = other.dev;
00081     return *this;
00082 }
00083 
00084 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00085 // senf::StatisticsBase
00086 
00087 prefix_ senf::StatisticsBase::StatisticsBase()
00088     : min_ (0.0f), avg_ (0.0f), max_ (0.0f), dev_ (0.0f), maxQueueLen_ (0u)
00089 {}
00090 
00091 prefix_ senf::StatisticsBase::~StatisticsBase()
00092 {}
00093 
00094 prefix_ senf::StatisticsBase::CollectorRange senf::StatisticsBase::collectors()
00095 {
00096     return senf::make_transform_range(children_, Transform());
00097 }
00098 
00099 prefix_ float senf::StatisticsBase::min()
00100     const
00101 {
00102     return min_;
00103 }
00104 
00105 prefix_ float senf::StatisticsBase::avg()
00106     const
00107 {
00108     return avg_;
00109 }
00110 
00111 prefix_ float senf::StatisticsBase::max()
00112     const
00113 {
00114     return max_;
00115 }
00116 
00117 prefix_ float senf::StatisticsBase::dev()
00118     const
00119 {
00120     return dev_;
00121 }
00122 
00123 prefix_ unsigned senf::StatisticsBase::rank()
00124     const
00125 {
00126     return 1;
00127 }
00128 
00129 prefix_ senf::Statistics & senf::StatisticsBase::base()
00130 {
00131     return v_base();
00132 }
00133 
00134 prefix_ std::string senf::StatisticsBase::path()
00135     const
00136 {
00137     return v_path();
00138 }
00139 
00140 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00141 // senf::Collector
00142 
00143 prefix_ senf::Collector::Collector(StatisticsBase * owner, unsigned rank)
00144     : rank_ (rank), i_ (0u), accMin_ (FLT_MAX), accSum_ (0.0f), accSumSq_ (0.0f), accMax_ (-FLT_MAX),
00145       owner_ (owner)
00146 {}
00147 
00148 prefix_ unsigned senf::Collector::rank()
00149     const
00150 {
00151     return rank_;
00152 }
00153 
00154 prefix_ senf::StatisticsBase::OutputProxy<senf::Collector>
00155 senf::Collector::output(unsigned n)
00156 {
00157 
00158     return StatisticsBase::OutputProxy<Collector>(this, StatisticsBase::output(n));
00159 }
00160 
00161 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00162 // senf::Statistics
00163 
00164 prefix_ void senf::Statistics::operator()(unsigned n, float min, float avg, float max,
00165                                           float dev)
00166 {
00167     enter(n, min, avg, max, dev);
00168 }
00169 
00170 prefix_ void senf::Statistics::operator()(float min, float avg, float max, float dev)
00171 {
00172     enter(1, min, avg, max, dev);
00173 }
00174 
00175 prefix_ void senf::Statistics::operator()(StatisticsData const & data)
00176 {
00177   enter(1, data.min, data.avg, data.max, data.stddev);
00178 }
00179 
00180 prefix_ void senf::Statistics::operator()(float value, float dev)
00181 {
00182     enter(1, value, value, value, dev);
00183 }
00184 
00185 
00186 prefix_ senf::StatisticsBase::OutputProxy<senf::Statistics>
00187 senf::Statistics::output(unsigned n)
00188 {
00189     return StatisticsBase::OutputProxy<Statistics>(this, StatisticsBase::output(n));
00190 }
00191 
00192 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00193 #undef prefix_
00194 
00195 
00196 // Local Variables:
00197 // mode: c++
00198 // fill-column: 100
00199 // comment-column: 40
00200 // c-file-style: "senf"
00201 // indent-tabs-mode: nil
00202 // ispell-local-dictionary: "american"
00203 // compile-command: "scons -u test"
00204 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research