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::read_char Struct Reference

I/O counter for chars read. The number of bytes which this task has caused to be read from storage. This is simply the sum of bytes which this process passed to read() and pread(). It includes things like tty IO and it is unaffected by whether or not actual physical disk IO was required (the read might have been satisfied from pagecache) More...

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

+ Collaboration diagram for tim::component::read_char:

Public Types

using this_type = read_char
 
using value_type = std::pair< int64_t, int64_t >
 
using base_type = base< this_type, value_type >
 
using result_type = std::pair< double, double >
 
using unit_type = typename trait::units< this_type >::type
 
using display_unit_type = typename trait::units< this_type >::display_type
 
using storage_type = empty_storage
 

Public Member Functions

std::string get_display () const
 
result_type get () const
 
void start ()
 
void stop ()
 
void sample ()
 sample a measurement More...
 
void sample (const cache_type &_cache)
 sample a measurement from cached data More...
 
void start (const cache_type &_cache)
 start a measurement using the cached data More...
 
void stop (const cache_type &_cache)
 stop a measurement using the cached data More...
 

Static Public Member Functions

static std::string label ()
 
static std::string description ()
 
static std::pair< double, double > unit ()
 
static std::vector< std::string > display_unit_array ()
 
static std::vector< std::string > label_array ()
 
static display_unit_type display_unit ()
 
static std::pair< double, double > unit_array ()
 
static std::vector< std::string > description_array ()
 
static auto get_timestamp ()
 
static value_type record ()
 
static auto get_timing_unit ()
 
static unit_type get_unit ()
 
static display_unit_type get_display_unit ()
 
static value_type record (const cache_type &_cache)
 read the value from cached data More...
 
template<typename... Args>
static opaque get_opaque (Args &&...)
 

Detailed Description

I/O counter for chars read. The number of bytes which this task has caused to be read from storage. This is simply the sum of bytes which this process passed to read() and pread(). It includes things like tty IO and it is unaffected by whether or not actual physical disk IO was required (the read might have been satisfied from pagecache)

Definition at line 54 of file components.hpp.

Member Typedef Documentation

◆ base_type

◆ display_unit_type

◆ result_type

using tim::component::read_char::result_type = std::pair<double, double>

Definition at line 59 of file components.hpp.

◆ storage_type

Definition at line 66 of file declaration.hpp.

◆ this_type

Definition at line 56 of file components.hpp.

◆ unit_type

◆ value_type

using tim::component::read_char::value_type = std::pair<int64_t, int64_t>

Definition at line 57 of file components.hpp.

Member Function Documentation

◆ description()

static std::string tim::component::read_char::description ( )
inlinestatic

Definition at line 64 of file components.hpp.

65 {
66 return "Number of bytes which this task has caused to be read from storage. Sum "
67 "of bytes which this process passed to read() and pread(). Not disk IO.";
68 }

◆ description_array()

static std::vector< std::string > tim::component::read_char::description_array ( )
inlinestatic

Definition at line 95 of file components.hpp.

96 {
97 return std::vector<std::string>{ "Number of char read", "Rate of char read" };
98 }

◆ display_unit()

static display_unit_type tim::component::read_char::display_unit ( )
inlinestatic

Definition at line 88 of file components.hpp.

89 {
90 return display_unit_type{ "MB", "MB/sec" };
91 }
typename trait::units< this_type >::display_type display_unit_type
Definition: components.hpp:61

Referenced by get_display_unit().

◆ display_unit_array()

static std::vector< std::string > tim::component::read_char::display_unit_array ( )
inlinestatic

Definition at line 77 of file components.hpp.

78 {
79 return std::vector<std::string>{ std::get<0>(get_display_unit()),
80 std::get<1>(get_display_unit()) };
81 }
static display_unit_type get_display_unit()
Definition: components.hpp:198

References get_display_unit().

◆ get()

result_type tim::component::read_char::get ( ) const
inline

Definition at line 139 of file components.hpp.

140 {
141 auto val = base_type::load();
142
143 double data = std::get<0>(val);
144 double delta = std::get<1>(val);
145
146 delta /= static_cast<double>(std::nano::den);
147 delta *= get_timing_unit();
148
149 double rate = 0.0;
150 if(delta != 0.0)
151 rate = data / delta;
152
153 if(laps > 0)
154 rate *= laps;
155
156 data /= std::get<0>(get_unit());
157 rate /= std::get<0>(get_unit());
158
159 if(!std::isfinite(rate))
160 rate = 0.0;
161
162 return result_type(data, rate);
163 }
bool isfinite(const Tp &arg)
Definition: utility.hpp:104
decltype(auto) load()
std::pair< double, double > result_type
Definition: components.hpp:59
static auto get_timing_unit()
Definition: components.hpp:104
static unit_type get_unit()
Definition: components.hpp:175

References get_timing_unit(), get_unit(), tim::isfinite(), tim::component::base< read_char, std::pair< int64_t, int64_t > >::laps, and tim::component::base< Tp, Value >::load().

Referenced by get_display().

◆ get_display()

std::string tim::component::read_char::get_display ( ) const
inline

Definition at line 112 of file components.hpp.

113 {
114 std::stringstream ss;
115 std::stringstream ssv;
116 std::stringstream ssr;
117 auto _prec = base_type::get_precision();
118 auto _width = base_type::get_width();
119 auto _flags = base_type::get_format_flags();
120 auto _disp = get_display_unit();
121
122 auto _val = get();
123
124 ssv.setf(_flags);
125 ssv << std::setw(_width) << std::setprecision(_prec) << std::get<0>(_val);
126 if(!std::get<0>(_disp).empty())
127 ssv << " " << std::get<0>(_disp);
128
129 ssr.setf(_flags);
130 ssr << std::setw(_width) << std::setprecision(_prec) << std::get<1>(_val);
131 if(!std::get<1>(_disp).empty())
132 ssr << " " << std::get<1>(_disp);
133
134 ss << ssv.str() << ", " << ssr.str();
135 ss << " rchar";
136 return ss.str();
137 }
static short get_precision()
static short get_width()
static fmtflags get_format_flags()
result_type get() const
Definition: components.hpp:139

References get(), get_display_unit(), tim::component::base< Tp, Value >::get_format_flags(), tim::component::base< Tp, Value >::get_precision(), and tim::component::base< Tp, Value >::get_width().

◆ get_display_unit()

static display_unit_type tim::component::read_char::get_display_unit ( )
inlinestatic

Definition at line 198 of file components.hpp.

199 {
200 static display_unit_type _instance = this_type::display_unit();
201 static auto& _mem = std::get<0>(_instance);
202 static auto& _rate = std::get<1>(_instance);
203
204 if(settings::memory_units().length() > 0)
205 _mem = std::get<0>(units::get_memory_unit(settings::memory_units()));
206
207 if(settings::timing_units().length() > 0)
208 {
209 auto _tval = std::get<0>(units::get_timing_unit(settings::timing_units()));
210 _rate = mpl::apply<std::string>::join('/', _mem, _tval);
211 }
212 else if(settings::memory_units().length() > 0)
213 {
214 _rate = mpl::apply<std::string>::join('/', _mem, "sec");
215 }
216
217 return _instance;
218 }
std::tuple< std::string, int64_t > get_timing_unit(std::string _unit)
Definition: units.hpp:229
std::tuple< std::string, int64_t > get_memory_unit(std::string _unit)
Definition: units.hpp:188
memory_units
Definition: settings.cpp:1657
timing_units
Definition: settings.cpp:1650
static display_unit_type display_unit()
Definition: components.hpp:88
static string_t join(SepT &&separator, Tuple &&__tup, index_sequence< Idx... >) noexcept
Definition: apply.hpp:408

References display_unit(), tim::units::get_memory_unit(), tim::units::get_timing_unit(), tim::mpl::apply< Ret >::join(), tim::memory_units, and tim::timing_units.

Referenced by display_unit_array(), and get_display().

◆ 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 }

◆ get_timestamp()

static auto tim::component::read_char::get_timestamp ( )
inlinestatic

Definition at line 100 of file components.hpp.

100{ return tim::get_clock_real_now<int64_t, std::nano>(); }

Referenced by record().

◆ get_timing_unit()

static auto tim::component::read_char::get_timing_unit ( )
inlinestatic

Definition at line 104 of file components.hpp.

105 {
106 static auto _value = units::sec;
107 if(settings::timing_units().length() > 0)
108 _value = std::get<1>(units::get_timing_unit(settings::timing_units()));
109 return _value;
110 }

References tim::units::get_timing_unit(), and tim::timing_units.

Referenced by get().

◆ get_unit()

static unit_type tim::component::read_char::get_unit ( )
inlinestatic

Definition at line 175 of file components.hpp.

176 {
177 static auto _instance = this_type::unit();
178 static auto& _mem = std::get<0>(_instance);
179 static auto& _rate = std::get<1>(_instance);
180
181 if(settings::memory_units().length() > 0)
182 _mem = std::get<1>(units::get_memory_unit(settings::memory_units()));
183
184 if(settings::timing_units().length() > 0)
185 {
186 auto _timing_val =
188 _rate = _mem / (_timing_val);
189 }
190
191 static const auto factor = static_cast<double>(std::nano::den);
192 unit_type _tmp = _instance;
193 std::get<1>(_tmp) *= factor;
194
195 return _tmp;
196 }
static std::pair< double, double > unit()
Definition: components.hpp:70
typename trait::units< this_type >::type unit_type
Definition: components.hpp:60

References tim::units::get_memory_unit(), tim::units::get_timing_unit(), tim::memory_units, tim::timing_units, and unit().

Referenced by get().

◆ label()

static std::string tim::component::read_char::label ( )
inlinestatic

Definition at line 63 of file components.hpp.

63{ return "read_char"; }

Referenced by label_array().

◆ label_array()

static std::vector< std::string > tim::component::read_char::label_array ( )
inlinestatic

Definition at line 83 of file components.hpp.

84 {
85 return std::vector<std::string>{ label(), "read_rate" };
86 }
static std::string label()
Definition: components.hpp:63

References label().

◆ record() [1/2]

static value_type tim::component::read_char::record ( )
inlinestatic

Definition at line 102 of file components.hpp.

102{ return value_type(get_char_read(), get_timestamp()); }
static auto get_timestamp()
Definition: components.hpp:100
std::pair< int64_t, int64_t > value_type
Definition: components.hpp:57

References get_timestamp().

Referenced by start(), and stop().

◆ record() [2/2]

static value_type tim::component::read_char::record ( const cache_type _cache)
inlinestatic

read the value from cached data

Definition at line 235 of file components.hpp.

236 {
237 return value_type{ _cache.get_char_read(), get_timestamp() };
238 }

References get_timestamp().

◆ sample() [1/2]

void tim::component::read_char::sample ( )
inline

sample a measurement

Definition at line 221 of file components.hpp.

222 {
223 std::get<0>(accum) = std::get<0>(value) =
224 std::max<int64_t>(std::get<0>(value), get_char_read());
225 }

◆ sample() [2/2]

void tim::component::read_char::sample ( const cache_type _cache)
inline

sample a measurement from cached data

Definition at line 228 of file components.hpp.

229 {
230 std::get<0>(accum) = std::get<0>(value) =
231 std::max<int64_t>(std::get<0>(value), _cache.get_char_read());
232 }

◆ start() [1/2]

void tim::component::read_char::start ( )
inline

Definition at line 165 of file components.hpp.

165{ value = record(); }
static value_type record()
Definition: components.hpp:102

References record().

◆ start() [2/2]

void tim::component::read_char::start ( const cache_type _cache)
inline

start a measurement using the cached data

Definition at line 241 of file components.hpp.

241{ value = record(_cache); }

References record().

◆ stop() [1/2]

void tim::component::read_char::stop ( )
inline

Definition at line 167 of file components.hpp.

168 {
169 using namespace tim::component::operators;
170 auto diff = (record() - value);
171 std::get<0>(diff) = std::abs(std::get<0>(diff));
172 accum += (value = diff);
173 }
type_list abs(type_list<>)
Definition: fwd.hpp:405

References tim::math::abs, and record().

◆ stop() [2/2]

void tim::component::read_char::stop ( const cache_type _cache)
inline

stop a measurement using the cached data

Definition at line 244 of file components.hpp.

245 {
246 using namespace tim::component::operators;
247 auto diff = (record(_cache) - value);
248 std::get<0>(diff) = std::abs(std::get<0>(diff));
249 accum += (value = diff);
250 }

References tim::math::abs, and record().

◆ unit()

static std::pair< double, double > tim::component::read_char::unit ( )
inlinestatic

Definition at line 70 of file components.hpp.

71 {
72 return std::pair<double, double>{
73 units::megabyte, static_cast<double>(units::megabyte) / units::sec
74 };
75 }

Referenced by get_unit(), and unit_array().

◆ unit_array()

static std::pair< double, double > tim::component::read_char::unit_array ( )
inlinestatic

Definition at line 93 of file components.hpp.

93{ return unit(); }

References unit().


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