timemory  3.2.1
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
 

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...
 

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 55 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 60 of file components.hpp.

◆ this_type

Definition at line 57 of file components.hpp.

◆ unit_type

◆ value_type

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

Definition at line 58 of file components.hpp.

Member Function Documentation

◆ description()

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

Definition at line 65 of file components.hpp.

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

◆ description_array()

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

Definition at line 96 of file components.hpp.

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

◆ display_unit()

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

Definition at line 89 of file components.hpp.

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

Referenced by get_display_unit(), tim::component::written_char::get_display_unit(), tim::component::read_bytes::get_display_unit(), and tim::component::written_bytes::get_display_unit().

◆ display_unit_array()

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

Definition at line 78 of file components.hpp.

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

References get_display_unit().

◆ get()

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

Definition at line 140 of file components.hpp.

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

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(), tim::component::written_char::get_display(), tim::component::read_bytes::get_display(), and tim::component::written_bytes::get_display().

◆ get_display()

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

Definition at line 113 of file components.hpp.

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

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 199 of file components.hpp.

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

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(), tim::component::written_char::display_unit_array(), tim::component::read_bytes::display_unit_array(), tim::component::written_bytes::display_unit_array(), get_display(), tim::component::written_char::get_display(), tim::component::read_bytes::get_display(), and tim::component::written_bytes::get_display().

◆ get_timestamp()

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

Definition at line 101 of file components.hpp.

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

Referenced by record(), tim::component::written_char::record(), tim::component::read_bytes::record(), and tim::component::written_bytes::record().

◆ get_timing_unit()

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

Definition at line 105 of file components.hpp.

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

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

Referenced by get(), tim::component::written_char::get(), tim::component::read_bytes::get(), and tim::component::written_bytes::get().

◆ get_unit()

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

Definition at line 176 of file components.hpp.

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

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

Referenced by get(), tim::component::written_char::get(), tim::component::read_bytes::get(), and tim::component::written_bytes::get().

◆ label()

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

◆ label_array()

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

Definition at line 84 of file components.hpp.

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

References label().

◆ record() [1/2]

◆ 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 236 of file components.hpp.

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

References get_timestamp().

◆ sample() [1/2]

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

sample a measurement

Definition at line 222 of file components.hpp.

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

◆ sample() [2/2]

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

sample a measurement from cached data

Definition at line 229 of file components.hpp.

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

◆ start() [1/2]

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

Definition at line 166 of file components.hpp.

166 { value = record(); }
static value_type record()
Definition: components.hpp:103

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 242 of file components.hpp.

242 { value = record(_cache); }

References record().

◆ stop() [1/2]

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

Definition at line 168 of file components.hpp.

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

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 245 of file components.hpp.

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

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

◆ unit()

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

Definition at line 71 of file components.hpp.

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

Referenced by get_unit(), tim::component::written_char::get_unit(), tim::component::read_bytes::get_unit(), tim::component::written_bytes::get_unit(), unit_array(), tim::component::written_char::unit_array(), tim::component::read_bytes::unit_array(), and tim::component::written_bytes::unit_array().

◆ unit_array()

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

Definition at line 94 of file components.hpp.

94 { return unit(); }

References unit().


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