4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief Statistics inline non-template implementation */
26 //#include "Statistics.ih"
30 #include <senf/Utils/Console/ParsedCommand.hh>
33 #define prefix_ inline
34 //-/////////////////////////////////////////////////////////////////////////////////////////////////
36 //-/////////////////////////////////////////////////////////////////////////////////////////////////
37 // senf::StatisticsBase::Transform
39 prefix_ senf::StatisticsBase::Transform::result_type
40 senf::StatisticsBase::Transform::operator()(first_argument_type i)
46 //-/////////////////////////////////////////////////////////////////////////////////////////////////
47 // senf::StatisticsBase::OutputEntry
49 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry()
50 : n(), min(), avg(), max(), dev()
55 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry(unsigned n_)
56 : n(n_), min(), avg(), max(), dev()
61 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry(const OutputEntry& other)
62 : n(other.n), min(other.min), avg(other.avg), max(other.max), dev(other.dev)
67 prefix_ void senf::StatisticsBase::OutputEntry::initDir()
69 dir.add("list", console::factory::Command(&OutputEntry::consoleList, this)
70 .doc("List all known connected targets. This list might not be complete.") );
73 prefix_ senf::StatisticsBase::OutputEntry &
74 senf::StatisticsBase::OutputEntry::operator=(const OutputEntry& other)
84 //-/////////////////////////////////////////////////////////////////////////////////////////////////
85 // senf::StatisticsBase
87 prefix_ senf::StatisticsBase::StatisticsBase()
88 : min_ (0.0f), avg_ (0.0f), max_ (0.0f), dev_ (0.0f), maxQueueLen_ (0u)
91 prefix_ senf::StatisticsBase::~StatisticsBase()
94 prefix_ senf::StatisticsBase::CollectorRange senf::StatisticsBase::collectors()
96 return senf::make_transform_range(children_, Transform());
99 prefix_ float senf::StatisticsBase::min()
105 prefix_ float senf::StatisticsBase::avg()
111 prefix_ float senf::StatisticsBase::max()
117 prefix_ float senf::StatisticsBase::dev()
123 prefix_ unsigned senf::StatisticsBase::rank()
129 prefix_ senf::Statistics & senf::StatisticsBase::base()
134 prefix_ std::string senf::StatisticsBase::path()
140 //-/////////////////////////////////////////////////////////////////////////////////////////////////
143 prefix_ senf::Collector::Collector(StatisticsBase * owner, unsigned rank)
144 : rank_ (rank), i_ (0u), accMin_ (FLT_MAX), accSum_ (0.0f), accSumSq_ (0.0f), accMax_ (-FLT_MAX),
148 prefix_ unsigned senf::Collector::rank()
154 prefix_ senf::StatisticsBase::OutputProxy<senf::Collector>
155 senf::Collector::output(unsigned n)
158 return StatisticsBase::OutputProxy<Collector>(this, StatisticsBase::output(n));
161 //-/////////////////////////////////////////////////////////////////////////////////////////////////
164 prefix_ void senf::Statistics::operator()(unsigned n, float min, float avg, float max,
167 enter(n, min, avg, max, dev);
170 prefix_ void senf::Statistics::operator()(float min, float avg, float max, float dev)
172 enter(1, min, avg, max, dev);
175 prefix_ void senf::Statistics::operator()(StatisticsData const & data)
177 enter(1, data.min, data.avg, data.max, data.stddev);
180 prefix_ void senf::Statistics::operator()(float value, float dev)
182 enter(1, value, value, value, dev);
186 prefix_ senf::StatisticsBase::OutputProxy<senf::Statistics>
187 senf::Statistics::output(unsigned n)
189 return StatisticsBase::OutputProxy<Statistics>(this, StatisticsBase::output(n));
192 //-/////////////////////////////////////////////////////////////////////////////////////////////////
199 // comment-column: 40
200 // c-file-style: "senf"
201 // indent-tabs-mode: nil
202 // ispell-local-dictionary: "american"
203 // compile-command: "scons -u test"