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 prefix_ senf::StatisticsData senf::StatisticsBase::data()
147 return StatisticsData(min_, avg_, max_, dev_, 0);
150 //-/////////////////////////////////////////////////////////////////////////////////////////////////
153 prefix_ senf::Collector::Collector(StatisticsBase * owner, unsigned rank)
154 : rank_ (rank), i_ (0u), accMin_ (FLT_MAX), accSum_ (0.0f), accSumSq_ (0.0f), accMax_ (-FLT_MAX),
158 prefix_ unsigned senf::Collector::rank()
164 prefix_ senf::StatisticsBase::OutputProxy<senf::Collector>
165 senf::Collector::output(unsigned n)
168 return StatisticsBase::OutputProxy<Collector>(this, StatisticsBase::output(n));
171 //-/////////////////////////////////////////////////////////////////////////////////////////////////
174 prefix_ void senf::Statistics::operator()(unsigned n, float min, float avg, float max,
177 enter(n, min, avg, max, dev);
180 prefix_ void senf::Statistics::operator()(float min, float avg, float max, float dev)
182 enter(1, min, avg, max, dev);
185 prefix_ void senf::Statistics::operator()(StatisticsData const & data)
187 enter(1, data.min, data.avg, data.max, data.stddev);
190 prefix_ void senf::Statistics::operator()(float value, float dev)
192 enter(1, value, value, value, dev);
196 prefix_ senf::StatisticsBase::OutputProxy<senf::Statistics>
197 senf::Statistics::output(unsigned n)
199 return StatisticsBase::OutputProxy<Statistics>(this, StatisticsBase::output(n));
202 //-/////////////////////////////////////////////////////////////////////////////////////////////////
209 // comment-column: 40
210 // c-file-style: "senf"
211 // indent-tabs-mode: nil
212 // ispell-local-dictionary: "american"
213 // compile-command: "scons -u test"