2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
15 \brief Statistics inline non-template implementation */
17 //#include "Statistics.ih"
21 #include <senf/Utils/Console/ParsedCommand.hh>
24 #define prefix_ inline
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 //-/////////////////////////////////////////////////////////////////////////////////////////////////
28 // senf::StatisticsBase::Transform
30 prefix_ senf::StatisticsBase::Transform::result_type
31 senf::StatisticsBase::Transform::operator()(first_argument_type i)
37 prefix_ senf::StatisticsBase::ConstTransform::result_type
38 senf::StatisticsBase::ConstTransform::operator()(first_argument_type i)
44 //-/////////////////////////////////////////////////////////////////////////////////////////////////
45 // senf::StatisticsBase::OutputEntry
47 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry()
48 : n(), cnt(), min(), avg(), max(), dev()
53 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry(unsigned n_)
54 : n(n_), cnt(), min(), avg(), max(), dev()
59 prefix_ senf::StatisticsBase::OutputEntry::OutputEntry(const OutputEntry& other)
60 : n(other.n), cnt(other.cnt), min(other.min), avg(other.avg), max(other.max), dev(other.dev)
65 prefix_ void senf::StatisticsBase::OutputEntry::initDir()
67 dir.add("list", console::factory::Command(&OutputEntry::consoleList, this)
68 .doc("List all known connected targets. This list might not be complete.") );
71 prefix_ senf::StatisticsBase::OutputEntry &
72 senf::StatisticsBase::OutputEntry::operator=(const OutputEntry& other)
83 //-/////////////////////////////////////////////////////////////////////////////////////////////////
84 // senf::StatisticsBase
86 prefix_ senf::StatisticsBase::StatisticsBase()
87 : cnt_(0), min_ (0.0f), avg_ (0.0f), max_ (0.0f), dev_ (0.0f), maxQueueLen_ (0u)
90 prefix_ senf::StatisticsBase::~StatisticsBase()
93 prefix_ senf::StatisticsBase::const_CollectorRange senf::StatisticsBase::collectors()
96 return senf::make_transform_range(children_, ConstTransform());
99 prefix_ senf::StatisticsBase::CollectorRange senf::StatisticsBase::collectors()
101 return senf::make_transform_range(children_, Transform());
104 prefix_ unsigned senf::StatisticsBase::cnt()
110 prefix_ float senf::StatisticsBase::min()
116 prefix_ float senf::StatisticsBase::avg()
122 prefix_ float senf::StatisticsBase::max()
128 prefix_ float senf::StatisticsBase::dev()
134 prefix_ unsigned senf::StatisticsBase::rank()
140 prefix_ senf::Statistics & senf::StatisticsBase::base()
145 prefix_ senf::Statistics const & senf::StatisticsBase::base()
148 return const_cast<StatisticsBase *>(this)->v_base();
151 prefix_ std::string senf::StatisticsBase::path()
157 prefix_ senf::StatisticsData senf::StatisticsBase::data()
160 return StatisticsData(min_, avg_, max_, dev_, cnt_);
163 //-/////////////////////////////////////////////////////////////////////////////////////////////////
166 prefix_ senf::Collector::Collector(StatisticsBase * owner, unsigned rank)
167 : rank_ (rank), i_ (0u), l_(0u), accCnt_(0), accMin_ (FLT_MAX), accSum_ (0.0f), accSumSq_ (0.0f), accMax_ (-FLT_MAX),
168 owner_ (owner), updated_(false)
171 prefix_ unsigned senf::Collector::rank()
177 prefix_ bool senf::Collector::updated()
184 prefix_ senf::StatisticsBase::OutputProxy<senf::Collector>
185 senf::Collector::output(unsigned n)
188 return StatisticsBase::OutputProxy<Collector>(this, StatisticsBase::output(n));
191 //-/////////////////////////////////////////////////////////////////////////////////////////////////
194 prefix_ void senf::Statistics::operator()(unsigned n, unsigned cnt, float min, float avg, float max,
197 enter(n, cnt, min, avg, max, dev);
200 prefix_ void senf::Statistics::operator()(unsigned cnt, float min, float avg, float max, float dev)
202 enter(1, cnt, min, avg, max, dev);
205 prefix_ void senf::Statistics::operator()(StatisticsData const & data)
207 enter(1, data.cnt, data.min, data.avg, data.max, data.stddev);
210 prefix_ void senf::Statistics::operator()(unsigned cnt, float value, float dev)
212 enter(1, cnt, value, value, value, dev);
216 prefix_ senf::StatisticsBase::OutputProxy<senf::Statistics>
217 senf::Statistics::output(unsigned n)
219 return StatisticsBase::OutputProxy<Statistics>(this, StatisticsBase::output(n));
222 //-/////////////////////////////////////////////////////////////////////////////////////////////////
229 // comment-column: 40
230 // c-file-style: "senf"
231 // indent-tabs-mode: nil
232 // ispell-local-dictionary: "american"
233 // compile-command: "scons -u test"