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

I/O counter for chars written. The number of bytes which this task has caused, or shall cause to be written to disk. Similar caveats apply here as with tim::component::read_char (rchar). More...

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

+ Collaboration diagram for tim::component::written_char:

Public Types

using this_type = written_char
 
using value_type = std::array< int64_t, 2 >
 
using base_type = base< this_type, value_type >
 
using result_type = std::array< double, 2 >
 
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 result_type unit ()
 
static std::vector< std::string > display_unit_array ()
 
static std::vector< std::string > label_array ()
 
static display_unit_type display_unit ()
 
static std::array< double, 2 > 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 written. The number of bytes which this task has caused, or shall cause to be written to disk. Similar caveats apply here as with tim::component::read_char (rchar).

Definition at line 259 of file components.hpp.

Member Typedef Documentation

◆ base_type

◆ display_unit_type

◆ result_type

using tim::component::written_char::result_type = std::array<double, 2>

Definition at line 264 of file components.hpp.

◆ this_type

◆ unit_type

◆ value_type

using tim::component::written_char::value_type = std::array<int64_t, 2>

Definition at line 262 of file components.hpp.

Member Function Documentation

◆ description()

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

Definition at line 269 of file components.hpp.

270  {
271  return "Number of bytes which this task has caused, or shall cause to be written "
272  "to disk. Similar caveats to read_char.";
273  }

◆ description_array()

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

Definition at line 299 of file components.hpp.

300  {
301  return std::vector<std::string>{ "Number of char written",
302  "Rate of char written" };
303  }

◆ display_unit()

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

Definition at line 292 of file components.hpp.

293  {
294  return display_unit_type{ { "MB", "MB/sec" } };
295  }
typename trait::units< this_type >::display_type display_unit_type
Definition: components.hpp:266

◆ display_unit_array()

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

Definition at line 281 of file components.hpp.

282  {
283  return std::vector<std::string>{ std::get<0>(get_display_unit()),
284  std::get<1>(get_display_unit()) };
285  }
static display_unit_type get_display_unit()
Definition: components.hpp:406

References tim::component::read_char::get_display_unit().

◆ get()

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

Definition at line 347 of file components.hpp.

348  {
349  auto val = base_type::load();
350 
351  double data = std::get<0>(val);
352  double delta = std::get<1>(val);
353 
354  delta /= static_cast<double>(std::nano::den);
355  delta *= get_timing_unit();
356 
357  double rate = 0.0;
358  if(delta != 0.0)
359  rate = data / delta;
360 
361  if(laps > 0)
362  rate *= laps;
363 
364  data /= std::get<0>(get_unit());
365  rate /= std::get<0>(get_unit());
366 
367  if(!std::isfinite(rate))
368  rate = 0.0;
369 
370  return result_type{ { data, rate } };
371  }
bool isfinite(const Tp &arg)
Definition: utility.hpp:127
decltype(auto) load()
static unit_type get_unit()
Definition: components.hpp:383
std::array< double, 2 > result_type
Definition: components.hpp:264

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

◆ get_display()

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

Definition at line 320 of file components.hpp.

321  {
322  std::stringstream ss;
323  std::stringstream ssv;
324  std::stringstream ssr;
325  auto _prec = base_type::get_precision();
326  auto _width = base_type::get_width();
327  auto _flags = base_type::get_format_flags();
328  auto _disp = get_display_unit();
329 
330  auto _val = get();
331 
332  ssv.setf(_flags);
333  ssv << std::setw(_width) << std::setprecision(_prec) << std::get<0>(_val);
334  if(!std::get<0>(_disp).empty())
335  ssv << " " << std::get<0>(_disp);
336 
337  ssr.setf(_flags);
338  ssr << std::setw(_width) << std::setprecision(_prec) << std::get<1>(_val);
339  if(!std::get<1>(_disp).empty())
340  ssr << " " << std::get<1>(_disp);
341 
342  ss << ssv.str() << ", " << ssr.str();
343  ss << " wchar";
344  return ss.str();
345  }
static short get_precision()
static short get_width()
static fmtflags get_format_flags()
result_type get() const
Definition: components.hpp:347

References tim::component::read_char::get(), tim::component::read_char::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::written_char::get_display_unit ( )
inlinestatic

Definition at line 406 of file components.hpp.

407  {
408  static display_unit_type _instance = this_type::display_unit();
409  static auto& _mem = std::get<0>(_instance);
410  static auto& _rate = std::get<1>(_instance);
411 
412  if(settings::memory_units().length() > 0)
413  _mem = std::get<0>(units::get_memory_unit(settings::memory_units()));
414 
415  if(settings::timing_units().length() > 0)
416  {
417  auto _tval = std::get<0>(units::get_timing_unit(settings::timing_units()));
418  _rate = mpl::apply<std::string>::join('/', _mem, _tval);
419  }
420  else if(settings::memory_units().length() > 0)
421  {
422  _rate = mpl::apply<std::string>::join('/', _mem, "sec");
423  }
424 
425  return _instance;
426  }
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:292
static string_t join(SepT &&separator, Tuple &&__tup, index_sequence< Idx... >) noexcept
Definition: apply.hpp:409

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

◆ get_timestamp()

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

Definition at line 305 of file components.hpp.

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

◆ get_timing_unit()

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

Definition at line 312 of file components.hpp.

313  {
314  static auto _value = units::sec;
315  if(settings::timing_units().length() > 0)
316  _value = std::get<1>(units::get_timing_unit(settings::timing_units()));
317  return _value;
318  }

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

◆ get_unit()

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

Definition at line 383 of file components.hpp.

384  {
385  static auto _instance = this_type::unit();
386  static auto& _mem = std::get<0>(_instance);
387  static auto& _rate = std::get<1>(_instance);
388 
389  if(settings::memory_units().length() > 0)
390  _mem = std::get<1>(units::get_memory_unit(settings::memory_units()));
391 
392  if(settings::timing_units().length() > 0)
393  {
394  auto _timing_val =
396  _rate = _mem / (_timing_val);
397  }
398 
399  static const auto factor = static_cast<double>(std::nano::den);
400  unit_type _tmp = _instance;
401  std::get<1>(_tmp) *= factor;
402 
403  return _tmp;
404  }
static result_type unit()
Definition: components.hpp:275
typename trait::units< this_type >::type unit_type
Definition: components.hpp:265

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

◆ label()

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

Definition at line 268 of file components.hpp.

268 { return "written_char"; }

◆ label_array()

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

Definition at line 287 of file components.hpp.

288  {
289  return std::vector<std::string>{ label(), "written_rate" };
290  }
static std::string label()
Definition: components.hpp:268

References tim::component::read_char::label().

◆ record() [1/2]

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

Definition at line 307 of file components.hpp.

308  {
309  return value_type{ { get_char_written(), get_timestamp() } };
310  }
std::array< int64_t, 2 > value_type
Definition: components.hpp:262

References tim::component::read_char::get_timestamp().

◆ record() [2/2]

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

read the value from cached data

Definition at line 443 of file components.hpp.

444  {
445  return value_type{ { _cache.get_char_written(), get_timestamp() } };
446  }

References tim::component::read_char::get_timestamp().

◆ sample() [1/2]

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

sample a measurement

Definition at line 429 of file components.hpp.

430  {
431  std::get<0>(accum) = std::get<0>(value) =
432  std::max<int64_t>(std::get<0>(value), get_char_written());
433  }

◆ sample() [2/2]

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

sample a measurement from cached data

Definition at line 436 of file components.hpp.

437  {
438  std::get<0>(accum) = std::get<0>(value) =
439  std::max<int64_t>(std::get<0>(value), _cache.get_char_written());
440  }

◆ start() [1/2]

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

Definition at line 373 of file components.hpp.

373 { value = record(); }
static value_type record()
Definition: components.hpp:307

References tim::component::read_char::record().

◆ start() [2/2]

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

start a measurement using the cached data

Definition at line 449 of file components.hpp.

449 { value = record(_cache); }

References tim::component::read_char::record().

◆ stop() [1/2]

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

Definition at line 375 of file components.hpp.

376  {
377  using namespace tim::component::operators;
378  auto diff = (record() - value);
379  std::get<0>(diff) = std::abs(std::get<0>(diff));
380  accum += (value = diff);
381  }
type_list abs(type_list<>)
Definition: math.hpp:155

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

◆ stop() [2/2]

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

stop a measurement using the cached data

Definition at line 452 of file components.hpp.

453  {
454  using namespace tim::component::operators;
455  auto diff = (record(_cache) - value);
456  std::get<0>(diff) = std::abs(std::get<0>(diff));
457  accum += (value = diff);
458  }

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

◆ unit()

static result_type tim::component::written_char::unit ( )
inlinestatic

Definition at line 275 of file components.hpp.

276  {
277  return result_type{ { units::megabyte,
278  static_cast<double>(units::megabyte) / units::sec } };
279  }

◆ unit_array()

static std::array<double, 2> tim::component::written_char::unit_array ( )
inlinestatic

Definition at line 297 of file components.hpp.

297 { return unit(); }

References tim::component::read_char::unit().


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