1 #ifndef __statCollector_h__
2 #define __statCollector_h__
12 base(
const std::string& aName,
13 const std::string& aUnit =
"s") :
name(aName),
unit(aUnit) {};
14 virtual void print(std::ostream&)
const = 0;
15 virtual void reset() = 0;
47 template <typename TT = T, typename std::enable_if <std::is_arithmetic<TT>::value>::type...,
class ... Types>
51 min(std::numeric_limits<T>::max()),
52 max(std::numeric_limits<T>::lowest()) {
54 template < typename TT = T, typename std::enable_if < !std::is_arithmetic<TT>::value >::type...,
class ... Types >
63 template<
typename TT = T>
64 typename std::enable_if < !std::is_arithmetic<TT>::value >::type
66 stream << this->
getName() <<
" avg: " << std::scientific
67 << std::chrono::duration_cast<std::chrono::duration<double>>(
sum / this->
n).count()
69 << std::chrono::duration_cast<std::chrono::duration<double>>(
min).count()
71 << std::chrono::duration_cast<std::chrono::duration<double>>(
max).count()
74 template<
typename TT = T>
75 typename std::enable_if <std::is_arithmetic<TT>::value>::type
77 stream << this->
getName() <<
" avg: "
86 void print(std::ostream& stream)
const override {
90 stream << this->
getName() <<
" no values yet ";
94 template<
typename TT = T>
95 typename std::enable_if < !std::is_arithmetic<TT>::value >::type
101 template<
typename TT = T>
102 typename std::enable_if <std::is_arithmetic<TT>::value>::type
105 min=std::numeric_limits<T>::max();
106 max=std::numeric_limits<T>::lowest();
115 inline std::chrono::system_clock::time_point
timePoint(
const struct timespec& spec) {
116 return std::chrono::system_clock::time_point(std::chrono::seconds(spec.tv_sec) +
117 std::chrono::nanoseconds(spec.tv_nsec));