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_bytes Struct Reference

I/O counter for bytes read. Attempt to count the number of bytes which this process really did cause to be fetched from the storage layer. Done at the submit_bio() level, so it is accurate for block-backed filesystems. More...

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

+ Collaboration diagram for tim::component::read_bytes:

Public Types

using this_type = read_bytes
 
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 the cache More...
 

Detailed Description

I/O counter for bytes read. Attempt to count the number of bytes which this process really did cause to be fetched from the storage layer. Done at the submit_bio() level, so it is accurate for block-backed filesystems.

Definition at line 466 of file components.hpp.

Member Typedef Documentation

◆ base_type

◆ display_unit_type

◆ result_type

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

Definition at line 471 of file components.hpp.

◆ this_type

◆ unit_type

◆ value_type

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

Definition at line 469 of file components.hpp.

Member Function Documentation

◆ description()

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

Definition at line 476 of file components.hpp.

477  {
478  return "Number of bytes which this process really did cause to be fetched from "
479  "the storage layer";
480  }

◆ description_array()

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

Definition at line 507 of file components.hpp.

508  {
509  return std::vector<std::string>{ "Number of bytes read", "Rate of bytes read" };
510  }

◆ display_unit()

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

Definition at line 500 of file components.hpp.

501  {
502  return display_unit_type{ "MB", "MB/sec" };
503  }
typename trait::units< this_type >::display_type display_unit_type
Definition: components.hpp:473

◆ display_unit_array()

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

Definition at line 489 of file components.hpp.

490  {
491  return std::vector<std::string>{ std::get<0>(get_display_unit()),
492  std::get<1>(get_display_unit()) };
493  }
static display_unit_type get_display_unit()
Definition: components.hpp:610

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

◆ get()

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

Definition at line 551 of file components.hpp.

552  {
553  auto val = base_type::load();
554 
555  double data = std::get<0>(val);
556  double delta = std::get<1>(val);
557 
558  delta /= static_cast<double>(std::nano::den);
559  delta *= get_timing_unit();
560 
561  double rate = 0.0;
562  if(delta != 0.0)
563  rate = data / delta;
564 
565  if(laps > 0)
566  rate *= laps;
567 
568  data /= std::get<0>(get_unit());
569  rate /= std::get<0>(get_unit());
570 
571  if(!std::isfinite(rate))
572  rate = 0.0;
573 
574  return result_type(data, rate);
575  }
bool isfinite(const Tp &arg)
Definition: utility.hpp:127
decltype(auto) load()
static unit_type get_unit()
Definition: components.hpp:587
static auto get_timing_unit()
Definition: components.hpp:516
std::pair< double, double > result_type
Definition: components.hpp:471

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::read_bytes::get_display ( ) const
inline

Definition at line 524 of file components.hpp.

525  {
526  std::stringstream ss;
527  std::stringstream ssv;
528  std::stringstream ssr;
529  auto _prec = base_type::get_precision();
530  auto _width = base_type::get_width();
531  auto _flags = base_type::get_format_flags();
532  auto _disp = get_display_unit();
533 
534  auto _val = get();
535 
536  ssv.setf(_flags);
537  ssv << std::setw(_width) << std::setprecision(_prec) << std::get<0>(_val);
538  if(!std::get<0>(_disp).empty())
539  ssv << " " << std::get<0>(_disp);
540 
541  ssr.setf(_flags);
542  ssr << std::setw(_width) << std::setprecision(_prec) << std::get<1>(_val);
543  if(!std::get<1>(_disp).empty())
544  ssr << " " << std::get<1>(_disp);
545 
546  ss << ssv.str() << ", " << ssr.str();
547  ss << " read_bytes";
548  return ss.str();
549  }
static short get_precision()
static short get_width()
static fmtflags get_format_flags()
result_type get() const
Definition: components.hpp:551

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::read_bytes::get_display_unit ( )
inlinestatic

Definition at line 610 of file components.hpp.

611  {
612  static display_unit_type _instance = this_type::display_unit();
613  static auto& _mem = std::get<0>(_instance);
614  static auto& _rate = std::get<1>(_instance);
615 
616  if(settings::memory_units().length() > 0)
617  _mem = std::get<0>(units::get_memory_unit(settings::memory_units()));
618 
619  if(settings::timing_units().length() > 0)
620  {
621  auto _tval = std::get<0>(units::get_timing_unit(settings::timing_units()));
622  _rate = mpl::apply<std::string>::join('/', _mem, _tval);
623  }
624  else if(settings::memory_units().length() > 0)
625  {
626  _rate = mpl::apply<std::string>::join('/', _mem, "sec");
627  }
628 
629  return _instance;
630  }
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:500
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::read_bytes::get_timestamp ( )
inlinestatic

Definition at line 512 of file components.hpp.

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

◆ get_timing_unit()

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

Definition at line 516 of file components.hpp.

517  {
518  static auto _value = units::sec;
519  if(settings::timing_units().length() > 0)
520  _value = std::get<1>(units::get_timing_unit(settings::timing_units()));
521  return _value;
522  }

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

◆ get_unit()

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

Definition at line 587 of file components.hpp.

588  {
589  static auto _instance = this_type::unit();
590  static auto& _mem = std::get<0>(_instance);
591  static auto& _rate = std::get<1>(_instance);
592 
593  if(settings::memory_units().length() > 0)
594  _mem = std::get<1>(units::get_memory_unit(settings::memory_units()));
595 
596  if(settings::timing_units().length() > 0)
597  {
598  auto _timing_val =
600  _rate = _mem / (_timing_val);
601  }
602 
603  static const auto factor = static_cast<double>(std::nano::den);
604  unit_type _tmp = _instance;
605  std::get<1>(_tmp) *= factor;
606 
607  return _tmp;
608  }
static std::pair< double, double > unit()
Definition: components.hpp:482
typename trait::units< this_type >::type unit_type
Definition: components.hpp:472

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::read_bytes::label ( )
inlinestatic

Definition at line 475 of file components.hpp.

475 { return "read_bytes"; }

◆ label_array()

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

Definition at line 495 of file components.hpp.

496  {
497  return std::vector<std::string>{ label(), "read_rate" };
498  }
static std::string label()
Definition: components.hpp:475

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

◆ record() [1/2]

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

Definition at line 514 of file components.hpp.

514 { return value_type(get_bytes_read(), get_timestamp()); }
std::pair< int64_t, int64_t > value_type
Definition: components.hpp:469

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

◆ record() [2/2]

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

read the value from the cache

Definition at line 647 of file components.hpp.

648  {
649  return value_type{ _cache.get_bytes_read(), get_timestamp() };
650  }

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

◆ sample() [1/2]

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

sample a measurement

Definition at line 633 of file components.hpp.

634  {
635  std::get<0>(accum) = std::get<0>(value) =
636  std::max<int64_t>(std::get<0>(value), get_bytes_read());
637  }

◆ sample() [2/2]

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

sample a measurement from cached data

Definition at line 640 of file components.hpp.

641  {
642  std::get<0>(accum) = std::get<0>(value) =
643  std::max<int64_t>(std::get<0>(value), _cache.get_bytes_read());
644  }

◆ start() [1/2]

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

Definition at line 577 of file components.hpp.

577 { value = record(); }
static value_type record()
Definition: components.hpp:514

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

◆ start() [2/2]

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

start a measurement using the cached data

Definition at line 653 of file components.hpp.

653 { value = record(_cache); }

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

◆ stop() [1/2]

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

Definition at line 579 of file components.hpp.

580  {
581  using namespace tim::component::operators;
582  auto diff = (record() - value);
583  std::get<0>(diff) = std::abs(std::get<0>(diff));
584  accum += (value = diff);
585  }
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::read_bytes::stop ( const cache_type _cache)
inline

stop a measurement using the cached data

Definition at line 656 of file components.hpp.

657  {
658  using namespace tim::component::operators;
659  auto diff = (record(_cache) - value);
660  std::get<0>(diff) = std::abs(std::get<0>(diff));
661  accum += (value = diff);
662  }

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

◆ unit()

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

Definition at line 482 of file components.hpp.

483  {
484  return std::pair<double, double>{
485  units::megabyte, static_cast<double>(units::megabyte) / units::sec
486  };
487  }

◆ unit_array()

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

Definition at line 505 of file components.hpp.

505 { return unit(); }

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


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