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::auto_list< Types > Class Template Reference

This is a variadic component wrapper where all components are optional at runtime. Accept unlimited number of parameters. The constructor starts the components, the destructor stops the components. The default behavior is to query the TIMEMORY_AUTO_LIST_INIT environment variable once (the first time the bundle is used) and use that list of components (if any) to initialize the components which are part of it's template parameters. This behavior can be modified by assigning a new lambda/functor to the reference which is returned from tim::auto_list<Types...>::get_initializer(). Assignment is not thread-safe since this is relatively unnecessary... if a different set of components are required on a particular thread, just create a different type with those particular components or pass the initialization functor to the constructor. More...

#include "timemory/variadic/auto_list.hpp"

+ Collaboration diagram for tim::auto_list< Types >:

Public Types

using this_type = auto_list< Types... >
 
using base_type = component_list< Types... >
 
using auto_type = this_type
 
using component_type = typename base_type::component_type
 
using type = convert_t< typename component_type::type, auto_list<> >
 

Public Member Functions

template<typename... Args>
 auto_list (Args &&... args)
 
 ~auto_list ()=default
 
 auto_list (const auto_list &)=default
 
 auto_list (auto_list &&)=default
 
auto_listoperator= (const auto_list &)=default
 
auto_listoperator= (auto_list &&)=default
 
this_typeprint (std::ostream &os, bool _endl=false) const
 

Static Public Member Functions

static constexpr std::size_t size ()
 

Friends

std::ostream & operator<< (std::ostream &os, const this_type &obj)
 

Detailed Description

template<typename... Types>
class tim::auto_list< Types >

This is a variadic component wrapper where all components are optional at runtime. Accept unlimited number of parameters. The constructor starts the components, the destructor stops the components. The default behavior is to query the TIMEMORY_AUTO_LIST_INIT environment variable once (the first time the bundle is used) and use that list of components (if any) to initialize the components which are part of it's template parameters. This behavior can be modified by assigning a new lambda/functor to the reference which is returned from tim::auto_list<Types...>::get_initializer(). Assignment is not thread-safe since this is relatively unnecessary... if a different set of components are required on a particular thread, just create a different type with those particular components or pass the initialization functor to the constructor.

Template Parameters
TypesSpecification of the component types to bundle together
void foo()
{
setenv("TIMEMORY_AUTO_LIST_COMPONENTS", "wall_clock", 0);
auto bar = bundle_t("bar");
bundle_t::get_initializer() = [](bundle_t& b)
{
b.initialize<cpu_clock, peak_rss>();
};
auto qix = bundle_t("qix");
auto local_init = [](bundle_t& b)
{
b.initialize<thread_cpu_clock, peak_rss>();
};
auto spam = bundle_t("spam", ..., local_init);
}
This is a variadic component wrapper where all components are optional at runtime....
Definition: auto_list.hpp:91

The above code will record wall-clock timer on first use of "bar", and will record cpu-clock, peak-rss at "qix", and peak-rss at "spam". If foo() is called a second time, "bar" will record cpu-clock and peak-rss. "spam" will always use the local initialized. If none of these initializers are set, wall-clock will be recorded for all of them. The intermediate storage will happen on the heap and when the destructor is called, it will add itself to the call-graph

Definition at line 88 of file auto_list.hpp.

Member Typedef Documentation

◆ auto_type

template<typename... Types>
using tim::auto_list< Types >::auto_type = this_type

Definition at line 98 of file auto_list.hpp.

◆ base_type

template<typename... Types>
using tim::auto_list< Types >::base_type = component_list<Types...>

Definition at line 97 of file auto_list.hpp.

◆ component_type

template<typename... Types>
using tim::auto_list< Types >::component_type = typename base_type::component_type

Definition at line 99 of file auto_list.hpp.

◆ this_type

template<typename... Types>
using tim::auto_list< Types >::this_type = auto_list<Types...>

Definition at line 96 of file auto_list.hpp.

◆ type

template<typename... Types>
using tim::auto_list< Types >::type = convert_t<typename component_type::type, auto_list<> >

Definition at line 100 of file auto_list.hpp.

Constructor & Destructor Documentation

◆ auto_list() [1/3]

template<typename... Types>
template<typename... Args>
tim::auto_list< Types >::auto_list ( Args &&...  args)
explicit

Definition at line 125 of file auto_list.hpp.

126: poly_base{ std::forward<Args>(args)... }
127{}

◆ ~auto_list()

template<typename... Types>
tim::auto_list< Types >::~auto_list ( )
default

◆ auto_list() [2/3]

template<typename... Types>
tim::auto_list< Types >::auto_list ( const auto_list< Types > &  )
default

◆ auto_list() [3/3]

template<typename... Types>
tim::auto_list< Types >::auto_list ( auto_list< Types > &&  )
default

Member Function Documentation

◆ operator=() [1/2]

template<typename... Types>
auto_list & tim::auto_list< Types >::operator= ( auto_list< Types > &&  )
default

◆ operator=() [2/2]

template<typename... Types>
auto_list & tim::auto_list< Types >::operator= ( const auto_list< Types > &  )
default

◆ print()

template<typename... Types>
auto_list< Types... > & tim::auto_list< Types >::print ( std::ostream &  os,
bool  _endl = false 
) const

Definition at line 131 of file auto_list.hpp.

132{
133 os << poly_base::m_temporary;
134 if(_endl)
135 os << '\n';
136 return const_cast<this_type&>(*this);
137}
auto_list< Types... > this_type
Definition: auto_list.hpp:96
const std::string std::ostream * os

References tim::os.

◆ size()

template<typename... Types>
static constexpr std::size_t tim::auto_list< Types >::size ( )
inlinestaticconstexpr

Definition at line 112 of file auto_list.hpp.

112{ return poly_base::size(); }

Friends And Related Function Documentation

◆ operator<<

template<typename... Types>
std::ostream & operator<< ( std::ostream &  os,
const this_type obj 
)
friend

Definition at line 116 of file auto_list.hpp.

117 {
118 obj.print(os, false);
119 return os;
120 }

The documentation for this class was generated from the following file: