51template <
typename CompT,
typename Tp>
56 using component_type = std::remove_pointer_t<decay_t<CompT>>;
57 using result_type =
decltype(std::declval<CompT>().get());
58 static_assert(std::is_same<result_type, Tp>::value,
59 "Error! The default implementation of "
60 "'policy::record_statistics<Component, T>::operator()' requires 'T' "
61 "to be the same type as the return type from 'Component::get()'");
65 if(_obj.get_laps() < 2)
72 "Updating statistics<%s> skipped for %s. Laps: %lu > "
74 demangle<Tp>().c_str(),
75 demangle<component_type>().c_str(),
76 (
unsigned long) _obj.get_laps());
84 IF_CONSTEXPR(has_accum) { _tmp.set_accum(_tmp.get_last()); }
85 else { _tmp.set_value(_tmp.get_last()); }
123 template <
typename StatsT>
126 (*this)(_obj, _stats, _last);
134 (*this)(_obj, _last);
140 template <
typename U>
141 TIMEMORY_INLINE
auto operator()(
const U& rhs,
bool _last =
false)
const
143 return sfinae(rhs, 0, 0, _last);
149 template <
typename StatsT,
typename U = type>
151 const U& rhs, StatsT& stats,
bool _last =
false,
157 template <
typename StatsT,
typename U = type>
159 const U&, StatsT&,
bool =
true,
164 template <
typename U>
165 TIMEMORY_INLINE
auto sfinae(
const U& rhs,
int,
int,
bool _last)
const
166 ->
decltype(rhs.update_statistics(_last))
168 return rhs.update_statistics(_last);
171 template <
typename U>
172 TIMEMORY_INLINE
auto sfinae(
const U& rhs,
int,
long,
bool _last)
const
173 ->
decltype(rhs.get_iterator()->stats(),
174 decay_t<
decltype(rhs.get_iterator()->stats())>{})
176 using stats_type =
decay_t<
decltype(rhs.get_iterator()->stats())>;
177 auto itr = rhs.get_iterator();
180 stats_type& _stats = itr->stats();
181 (*this)(rhs, _stats, _last);
187 template <
typename U>
188 TIMEMORY_INLINE
void sfinae(
const U&,
long,
long,
bool)
const
193template <
typename StatsT,
typename U>
196 const U& rhs, StatsT& stats,
bool _last,
206 std::is_same<incoming_t, expected_t>::value,
207 "add_statistics was passed a data type different than declared "
208 "trait::statistics type. To disable this error, e.g. permit "
209 "implicit conversion, set trait::permissive_statistics "
210 "to true_type for component");
213 demangle<StatsT>().c_str(), (_last) ?
"y" :
"n");
214 stats_policy_type{}(stats, rhs, _last);
#define IF_CONSTEXPR(...)
typename std::decay< T >::type decay_t
Alias template for decay.
typename std::enable_if< B, T >::type enable_if_t
Alias template for enable_if.
The declaration for the types for operations without definitions.
Include the macros for operations.
Declare the operations types.
Enabling statistics in timemory has two parts:
add_statistics(const type &_obj, StatsT &_stats, bool _last=false)
add_statistics(const type &_obj, bool _last=false)
auto operator()(const U &rhs, bool _last=false) const
void operator()(const U &, StatsT &, bool=true, enable_if_t<!enabled_statistics< U, StatsT >::value, int >=0) const
Specification of how to accumulate statistics. This will not be used unless tim::trait::statistics ha...
void operator()(statistics< type > &, const CompT &, bool _accum=true)
A generic class for statistical accumulation. It uses the timemory math overloads to enable statistic...
trait that signifies that a component has an accumulation value. In general, most components implemen...
trait that will suppress compilation error in operation::add_statistics<Component> if the data type p...
#define CONDITIONAL_PRINT_HERE(CONDITION,...)
#define DEBUG_PRINT_HERE(...)