17 #ifndef HH_SENF_Utils_Statistics_ 18 #define HH_SENF_Utils_Statistics_ 1 24 #include <boost/iterator/transform_iterator.hpp> 25 #include <boost/range/iterator_range.hpp> 26 #include <boost/noncopyable.hpp> 27 #include <boost/ptr_container/ptr_vector.hpp> 28 #include <boost/signals2.hpp> 30 #include <senf/Utils/Cpp11Support/smart_ptr.hh> 61 typedef std::map<unsigned, Collector> Children;
65 typedef Children::value_type & first_argument_type;
67 result_type operator()(first_argument_type i)
const;
69 struct ConstTransform {
70 typedef Children::value_type
const & first_argument_type;
72 result_type operator()(first_argument_type i)
const;
75 typedef boost::transform_iterator<Transform,Children::iterator> ValueIterator;
76 typedef boost::transform_iterator<ConstTransform,Children::const_iterator> const_ValueIterator;
122 template <
class Owner>
126 template <
class Target> Owner &
connect(Target & target,
127 std::string label=
"")
const;
129 template <
class PTarget> Owner & connect(std::unique_ptr<PTarget> target,
130 std::string label=
"")
const;
132 Owner & noconnect()
const;
140 template <
class OtherOwner>
145 OutputEntry * entry_;
154 unsigned cnt ()
const;
160 virtual unsigned rank()
const;
208 std::string
path()
const;
246 void consoleList(
unsigned level, std::ostream & os)
const;
255 virtual std::string v_path()
const = 0;
257 void generateOutput();
273 QueueEntry(
unsigned cnt_,
float min_,
float avg_,
float max_,
float dev_)
276 typedef std::deque<QueueEntry> Queue;
282 explicit TargetBase(std::string
const & label_) : label (label_) {}
287 template <
class PTarget>
291 Target(std::unique_ptr<PTarget> target, std::string
const & label)
292 :
TargetBase (label), target_ (target.release()) {}
293 explicit Target(std::string
const & label)
298 explicit OutputEntry(
unsigned n_);
299 OutputEntry(
const OutputEntry& other);
300 OutputEntry& operator=(
const OutputEntry& other);
312 boost::signals2::signal<void(unsigned,float,float,float,float)>
signal;
313 boost::ptr_vector<TargetBase> targets_;
317 typedef std::map<unsigned, OutputEntry> OutputMap;
319 unsigned maxQueueLen_;
439 #ifndef SENF_DISABLE_CONSOLE 445 void operator()(
unsigned n,
unsigned cnt,
float min,
float avg,
float max,
float dev);
473 void operator()(
unsigned cnt,
float min,
float avg,
float max,
float dev=0.0f);
477 void operator()(
unsigned cnt,
float value,
float dev=0.0f);
485 template <
class Value>
497 void consoleCollect(std::vector<unsigned> & ranks);
499 boost::shared_ptr<console::DirectoryNode> consoleOutput(
500 std::vector<unsigned> & ranks,
unsigned window);
502 std::string v_path()
const;
515 virtual unsigned rank()
const;
519 bool updated()
const;
525 std::string v_path()
const;
std::string path() const
Get the path to this collector.
Accumulate measurement values.
OutputProxy< StatisticsBase > output(unsigned n=1u)
Register output.
StatisticsData data() const
Get the Statistics data as senf::StatisticsData.
TargetBase(std::string const &label_)
Internal: Generic Statistics collection.
Target(std::string const &label)
unsigned cnt() const
Last cnt value entered.
Collector & operator[](unsigned rank)
Get child collector.
StatsDataCollectorKernel signal
Collect statistics and generate log messages.
StatisticAccumulator public header.
void connect(connector::FastActiveOutput< PacketType > &source, connector::FastPassiveInput< PacketType > &target)
float avg() const
Last avg value entered.
float max() const
Last max value entered.
boost::iterator_range< ValueIterator > CollectorRange
float dev() const
Last dev value entered.
virtual ~StatisticsBase()
boost::scoped_ptr< PTarget > target_
boost::iterator_range< const_ValueIterator > const_CollectorRange
Statistics const & base() const
Output connection interface.
Accumulated statistics collector.
Extensible exception base-class.
CollectorRange collectors()
List all child collectors.
console::ScopedDirectory dir
void consoleList(unsigned level, std::ostream &os) const
Target(std::unique_ptr< PTarget > target, std::string const &label)
void enter(unsigned n, unsigned cnt, float min, float avg, float max, float dev)
Collector & collect(unsigned rank)
Register a new collector.
virtual unsigned rank() const
Return collectors rank value.
float min() const
Last min value entered.