4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief Statistics inline non-template implementation */
31 //#include "Statistics.ih"
35 #include <senf/Utils/Console/ParsedCommand.hh>
38 #define prefix_ inline
39 //-/////////////////////////////////////////////////////////////////////////////////////////////////
41 //-/////////////////////////////////////////////////////////////////////////////////////////////////
42 // senf::StatisticsBase::Transform
44 prefix_ senf::StatisticsBase::Transform::result_type
45 senf::StatisticsBase::Transform::operator()(first_argument_type i)
51 //-/////////////////////////////////////////////////////////////////////////////////////////////////
52 // senf::StatisticsBase::OutputEntry
54 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry()
55 : n(), min(), avg(), max(), dev()
60 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry(unsigned n_)
61 : n(n_), min(), avg(), max(), dev()
66 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry(const OutputEntry& other)
67 : n(other.n), min(other.min), avg(other.avg), max(other.max), dev(other.dev)
72 prefix_ void senf::StatisticsBase::OutputEntry::initDir()
74 dir.add("list", console::factory::Command(&OutputEntry::consoleList, this)
75 .doc("List all known connected targets. This list might not be complete.") );
78 prefix_ senf::StatisticsBase::OutputEntry &
79 senf::StatisticsBase::OutputEntry::operator=(const OutputEntry& other)
89 //-/////////////////////////////////////////////////////////////////////////////////////////////////
90 // senf::StatisticsBase
92 prefix_ senf::StatisticsBase::StatisticsBase()
93 : min_ (0.0f), avg_ (0.0f), max_ (0.0f), dev_ (0.0f), maxQueueLen_ (0u)
96 prefix_ senf::StatisticsBase::~StatisticsBase()
99 prefix_ senf::StatisticsBase::CollectorRange senf::StatisticsBase::collectors()
101 return senf::make_transform_range(children_, Transform());
104 prefix_ float senf::StatisticsBase::min()
110 prefix_ float senf::StatisticsBase::avg()
116 prefix_ float senf::StatisticsBase::max()
122 prefix_ float senf::StatisticsBase::dev()
128 prefix_ unsigned senf::StatisticsBase::rank()
134 prefix_ senf::Statistics & senf::StatisticsBase::base()
139 prefix_ std::string senf::StatisticsBase::path()
145 //-/////////////////////////////////////////////////////////////////////////////////////////////////
148 prefix_ senf::Collector::Collector(StatisticsBase * owner, unsigned rank)
149 : rank_ (rank), i_ (0u), accMin_ (FLT_MAX), accSum_ (0.0f), accSumSq_ (0.0f), accMax_ (-FLT_MAX),
153 prefix_ unsigned senf::Collector::rank()
159 prefix_ senf::StatisticsBase::OutputProxy<senf::Collector>
160 senf::Collector::output(unsigned n)
163 return StatisticsBase::OutputProxy<Collector>(this, StatisticsBase::output(n));
166 //-/////////////////////////////////////////////////////////////////////////////////////////////////
169 prefix_ void senf::Statistics::operator()(unsigned n, float min, float avg, float max,
172 enter(n, min, avg, max, dev);
175 prefix_ void senf::Statistics::operator()(float min, float avg, float max, float dev)
177 enter(1, min, avg, max, dev);
180 prefix_ void senf::Statistics::operator()(StatisticsData const & data)
182 enter(1, data.min, data.avg, data.max, data.stddev);
185 prefix_ void senf::Statistics::operator()(float value, float dev)
187 enter(1, value, value, value, dev);
191 prefix_ senf::StatisticsBase::OutputProxy<senf::Statistics>
192 senf::Statistics::output(unsigned n)
194 return StatisticsBase::OutputProxy<Statistics>(this, StatisticsBase::output(n));
197 //-/////////////////////////////////////////////////////////////////////////////////////////////////
204 // comment-column: 40
205 // c-file-style: "senf"
206 // indent-tabs-mode: nil
207 // ispell-local-dictionary: "american"
208 // compile-command: "scons -u test"