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::component::printer Struct Reference

A diagnostic component when prints messages via start(...) and stores messages via store(...). The stored messages are returned via the get() member function. If bundled alongside the timestamp component, the timestamp will be added to the stored message. More...

#include "timemory/components/printer/printer.hpp"

+ Collaboration diagram for tim::component::printer:

Public Types

using value_type = void
 
using storage_type = empty_storage
 
using base_type = void
 

Public Member Functions

 printer ()=default
 
 ~printer ()=default
 
 printer (printer &&)=default
 
 printer (const printer &)
 
printeroperator= (printer &&)=default
 
printeroperator= (const printer &)
 
std::string get () const
 
void set_prefix (const char *)
 
bool assemble (timestamp *)
 
template<typename... Args>
auto start (Args &&... args) -> decltype(TIMEMORY_FOLD_EXPRESSION(std::declval< std::stringstream >()<< args), void())
 
template<typename... Args>
auto store (Args &&... args) -> decltype(TIMEMORY_FOLD_EXPRESSION(std::declval< std::stringstream >()<< args), void())
 

Static Public Member Functions

static std::string label ()
 
static std::string description ()
 
static std::string get_label ()
 
static std::string get_description ()
 
template<typename... Args>
static opaque get_opaque (Args &&...)
 

Detailed Description

A diagnostic component when prints messages via start(...) and stores messages via store(...). The stored messages are returned via the get() member function. If bundled alongside the timestamp component, the timestamp will be added to the stored message.

Definition at line 43 of file printer.hpp.

Member Typedef Documentation

◆ base_type

using tim::component::empty_base::base_type = void
inherited

Definition at line 67 of file declaration.hpp.

◆ storage_type

Definition at line 66 of file declaration.hpp.

◆ value_type

Definition at line 47 of file printer.hpp.

Constructor & Destructor Documentation

◆ printer() [1/3]

tim::component::printer::printer ( )
default

◆ ~printer()

tim::component::printer::~printer ( )
default

◆ printer() [2/3]

tim::component::printer::printer ( printer &&  )
default

◆ printer() [3/3]

tim::component::printer::printer ( const printer rhs)

Definition at line 70 of file printer.cpp.

71: m_prefix{ rhs.m_prefix }
72, m_ts{ rhs.m_ts }
73, m_stream{ rhs.m_stream.str() }
74{}

Member Function Documentation

◆ assemble()

bool tim::component::printer::assemble ( timestamp _wc)

Definition at line 106 of file printer.cpp.

107{
108 m_ts = _wc;
109 return (m_ts != nullptr);
110}

◆ description()

std::string tim::component::printer::description ( )
static

Definition at line 50 of file printer.cpp.

51{
52 return "Provides an interface for printing out debug messages";
53}

Referenced by get_description().

◆ get()

std::string tim::component::printer::get ( ) const

Definition at line 92 of file printer.cpp.

93{
94 return m_stream.str();
95}

◆ get_description()

std::string tim::component::printer::get_description ( )
static

Definition at line 64 of file printer.cpp.

65{
66 return description();
67}
static std::string description()
Definition: printer.cpp:50

References description().

◆ get_label()

std::string tim::component::printer::get_label ( )
static

Definition at line 57 of file printer.cpp.

58{
59 return label();
60}
static std::string label()
Definition: printer.cpp:43

References label().

◆ get_opaque()

template<typename... Args>
static opaque tim::component::empty_base::get_opaque ( Args &&  ...)
inlinestaticinherited

Definition at line 72 of file declaration.hpp.

73 {
74 return opaque{};
75 }

◆ label()

std::string tim::component::printer::label ( )
static

Definition at line 43 of file printer.cpp.

44{
45 return "printer";
46}

Referenced by get_label().

◆ operator=() [1/2]

printer & tim::component::printer::operator= ( const printer rhs)

Definition at line 78 of file printer.cpp.

79{
80 if(this == &rhs)
81 return *this;
82
83 m_prefix = rhs.m_prefix;
84 m_ts = rhs.m_ts;
85 m_stream << rhs.m_stream.str();
86
87 return *this;
88}

◆ operator=() [2/2]

printer & tim::component::printer::operator= ( printer &&  )
default

◆ set_prefix()

void tim::component::printer::set_prefix ( const char *  _prefix)

Definition at line 99 of file printer.cpp.

100{
101 m_prefix = _prefix;
102}
char const std::string & _prefix
Definition: config.cpp:55

References tim::_prefix.

◆ start()

template<typename... Args>
auto tim::component::printer::start ( Args &&...  args) -> decltype(TIMEMORY_FOLD_EXPRESSION(std::declval<std::stringstream>() << args), void())

Definition at line 91 of file printer.hpp.

94{
95 // only print message if arguments provided
96 if(sizeof...(Args) == 0)
97 return;
98
99 std::cerr << std::flush;
100 if(m_prefix)
101 std::cerr << "[" << m_prefix << "]";
102 std::cerr << "> " << TIMEMORY_JOIN("", std::forward<Args>(args)...) << '\n';
103}
#define TIMEMORY_JOIN(delim,...)
Definition: macros.hpp:90

References TIMEMORY_JOIN.

◆ store()

template<typename... Args>
auto tim::component::printer::store ( Args &&...  args) -> decltype(TIMEMORY_FOLD_EXPRESSION(std::declval<std::stringstream>() << args), void())

Definition at line 107 of file printer.hpp.

110{
111 // only store message if arguments provided
112 if(sizeof...(Args) == 0)
113 return;
114
115 std::string _tp{};
116 if(m_prefix)
117 _tp += TIMEMORY_JOIN("", '[', m_prefix, ']');
118 if(m_ts)
119 _tp += "[" + timestamp::as_string(m_ts->get()) + "]";
120 m_stream << _tp << "> " << TIMEMORY_JOIN("", std::forward<Args>(args)...) << '\n';
121}
tim::mpl::apply< std::string > string
Definition: macros.hpp:53
static std::string as_string(const time_point_type &_tp)
Definition: timestamp.cpp:64
value_type get() const
Definition: timestamp.cpp:100

References tim::trait::as_string(), and TIMEMORY_JOIN.


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