timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
tim::policy::record_statistics< CompT, Tp > Struct Template Reference

Specification of how to accumulate statistics. This will not be used unless tim::trait::statistics has been assigned a type and tim::trait::record_statistics is true. Set tim::trait::permissive_statistics to allow implicit conversions, e.g. int -> size_t. More...

#include "timemory/mpl/policy.hpp"

+ Collaboration diagram for tim::policy::record_statistics< CompT, Tp >:

Public Types

using type = Tp
 
using this_type = record_statistics< CompT, type >
 
using policy_type = this_type
 
using statistics_type = statistics< type >
 

Public Member Functions

void operator() (statistics< type > &, const CompT &, bool _accum=true)
 
void operator() (type &, const CompT &)
 

Detailed Description

template<typename CompT, typename Tp>
struct tim::policy::record_statistics< CompT, Tp >

Specification of how to accumulate statistics. This will not be used unless tim::trait::statistics has been assigned a type and tim::trait::record_statistics is true. Set tim::trait::permissive_statistics to allow implicit conversions, e.g. int -> size_t.

template <typename CompT, typename Tp>
struct record_statistics
{
using type = Tp;
using component_type = CompT;
using statistics_type = statistics<type>;
static void apply(statistics_type& stats, const component_type& obj)
{
// example:
// typeid(stats) is tim::statistics<double>
// obj.get() returns a double precision value
stats += obj.get();
}
};
statistics< type > statistics_type
Definition: policy.hpp:52

Definition at line 47 of file policy.hpp.

Member Typedef Documentation

◆ policy_type

template<typename CompT , typename Tp >
using tim::policy::record_statistics< CompT, Tp >::policy_type = this_type

Definition at line 51 of file policy.hpp.

◆ statistics_type

template<typename CompT , typename Tp >
using tim::policy::record_statistics< CompT, Tp >::statistics_type = statistics<type>

Definition at line 52 of file policy.hpp.

◆ this_type

template<typename CompT , typename Tp >
using tim::policy::record_statistics< CompT, Tp >::this_type = record_statistics<CompT, type>

Definition at line 50 of file policy.hpp.

◆ type

template<typename CompT , typename Tp >
using tim::policy::record_statistics< CompT, Tp >::type = Tp

Definition at line 49 of file policy.hpp.

Member Function Documentation

◆ operator()() [1/2]

template<typename CompT , typename Tp >
void tim::policy::record_statistics< CompT, Tp >::operator() ( statistics< type > &  _stats,
const CompT &  _obj,
bool  _accum = true 
)
inline

Definition at line 53 of file add_statistics.hpp.

55{
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()'");
62
63 if(!_last)
64 {
65 if(_obj.get_laps() < 2)
66 {
67 _stats += _obj.get();
68 }
69 else
70 {
72 "Updating statistics<%s> skipped for %s. Laps: %lu > "
73 "1",
74 demangle<Tp>().c_str(),
75 demangle<component_type>().c_str(),
76 (unsigned long) _obj.get_laps());
77 }
78 }
79 else
80 {
81 constexpr bool has_accum = trait::base_has_accum<component_type>::value;
82 // make a copy and replace the accumulation with last measurement
83 auto _tmp = _obj;
84 IF_CONSTEXPR(has_accum) { _tmp.set_accum(_tmp.get_last()); }
85 else { _tmp.set_value(_tmp.get_last()); }
86 _stats += _tmp.get();
87 }
88}
#define IF_CONSTEXPR(...)
Definition: language.hpp:72
#define CONDITIONAL_PRINT_HERE(CONDITION,...)
Definition: macros.hpp:183

References CONDITIONAL_PRINT_HERE, tim::debug, and IF_CONSTEXPR.

◆ operator()() [2/2]

template<typename CompT , typename Tp >
void tim::policy::record_statistics< CompT, Tp >::operator() ( type ,
const CompT &   
)
inline

Definition at line 55 of file policy.hpp.

55{}

The documentation for this struct was generated from the following files: