00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026
00027
00028
00029 #include <float.h>
00030 #include <senf/Utils/Console/ParsedCommand.hh>
00031 #include "Range.hh"
00032
00033 #define prefix_ inline
00034
00035
00036
00037
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
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
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
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
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
00197
00198
00199
00200
00201
00202
00203
00204