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

I/O counter for bytes written. Attempt to count the number of bytes which this process caused to be sent to the storage layer. This is done at page-dirtying time. More...

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

+ Collaboration diagram for tim::component::written_bytes:

Public Types

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

Detailed Description

I/O counter for bytes written. Attempt to count the number of bytes which this process caused to be sent to the storage layer. This is done at page-dirtying time.

Definition at line 669 of file components.hpp.

Member Typedef Documentation

◆ base_type

◆ display_unit_type

◆ result_type

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

Definition at line 674 of file components.hpp.

◆ this_type

◆ unit_type

◆ value_type

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

Definition at line 672 of file components.hpp.

Member Function Documentation

◆ description()

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

Definition at line 679 of file components.hpp.

680  {
681  return "Number of bytes sent to the storage layer";
682  }

◆ description_array()

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

Definition at line 708 of file components.hpp.

709  {
710  return std::vector<std::string>{ "Number of bytes written",
711  "Rate of bytes written" };
712  }

◆ display_unit()

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

Definition at line 701 of file components.hpp.

702  {
703  return display_unit_type{ { "MB", "MB/sec" } };
704  }
typename trait::units< this_type >::display_type display_unit_type
Definition: components.hpp:676

◆ display_unit_array()

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

Definition at line 690 of file components.hpp.

691  {
692  return std::vector<std::string>{ std::get<0>(get_display_unit()),
693  std::get<1>(get_display_unit()) };
694  }
static display_unit_type get_display_unit()
Definition: components.hpp:815

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

◆ get()

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

Definition at line 756 of file components.hpp.

757  {
758  auto val = base_type::load();
759 
760  double data = std::get<0>(val);
761  double delta = std::get<1>(val);
762 
763  delta /= static_cast<double>(std::nano::den);
764  delta *= get_timing_unit();
765 
766  double rate = 0.0;
767  if(delta != 0.0)
768  rate = data / delta;
769 
770  if(laps > 0)
771  rate *= laps;
772 
773  data /= std::get<0>(get_unit());
774  rate /= std::get<0>(get_unit());
775 
776  if(!std::isfinite(rate))
777  rate = 0.0;
778 
779  return result_type{ { data, rate } };
780  }
bool isfinite(const Tp &arg)
Definition: utility.hpp:127
decltype(auto) load()
static unit_type get_unit()
Definition: components.hpp:792
std::array< double, 2 > result_type
Definition: components.hpp:674

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

Definition at line 729 of file components.hpp.

730  {
731  std::stringstream ss;
732  std::stringstream ssv;
733  std::stringstream ssr;
734  auto _prec = base_type::get_precision();
735  auto _width = base_type::get_width();
736  auto _flags = base_type::get_format_flags();
737  auto _disp = get_display_unit();
738 
739  auto _val = get();
740 
741  ssv.setf(_flags);
742  ssv << std::setw(_width) << std::setprecision(_prec) << std::get<0>(_val);
743  if(!std::get<0>(_disp).empty())
744  ssv << " " << std::get<0>(_disp);
745 
746  ssr.setf(_flags);
747  ssr << std::setw(_width) << std::setprecision(_prec) << std::get<1>(_val);
748  if(!std::get<1>(_disp).empty())
749  ssr << " " << std::get<1>(_disp);
750 
751  ss << ssv.str() << ", " << ssr.str();
752  ss << " write_bytes";
753  return ss.str();
754  }
static short get_precision()
static short get_width()
static fmtflags get_format_flags()
result_type get() const
Definition: components.hpp:756

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

Definition at line 815 of file components.hpp.

816  {
817  static display_unit_type _instance = this_type::display_unit();
818  static auto& _mem = std::get<0>(_instance);
819  static auto& _rate = std::get<1>(_instance);
820 
821  if(settings::memory_units().length() > 0)
822  _mem = std::get<0>(units::get_memory_unit(settings::memory_units()));
823 
824  if(settings::timing_units().length() > 0)
825  {
826  auto _tval = std::get<0>(units::get_timing_unit(settings::timing_units()));
827  _rate = mpl::apply<std::string>::join('/', _mem, _tval);
828  }
829  else if(settings::memory_units().length() > 0)
830  {
831  _rate = mpl::apply<std::string>::join('/', _mem, "sec");
832  }
833 
834  return _instance;
835  }
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:701
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_bytes::get_timestamp ( )
inlinestatic

Definition at line 714 of file components.hpp.

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

◆ get_timing_unit()

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

Definition at line 721 of file components.hpp.

722  {
723  static auto _value = units::sec;
724  if(settings::timing_units().length() > 0)
725  _value = std::get<1>(units::get_timing_unit(settings::timing_units()));
726  return _value;
727  }

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

◆ get_unit()

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

Definition at line 792 of file components.hpp.

793  {
794  static auto _instance = this_type::unit();
795  static auto& _mem = std::get<0>(_instance);
796  static auto& _rate = std::get<1>(_instance);
797 
798  if(settings::memory_units().length() > 0)
799  _mem = std::get<1>(units::get_memory_unit(settings::memory_units()));
800 
801  if(settings::timing_units().length() > 0)
802  {
803  auto _timing_val =
805  _rate = _mem / (_timing_val);
806  }
807 
808  static const auto factor = static_cast<double>(std::nano::den);
809  unit_type _tmp = _instance;
810  std::get<1>(_tmp) *= factor;
811 
812  return _tmp;
813  }
typename trait::units< this_type >::type unit_type
Definition: components.hpp:675
static result_type unit()
Definition: components.hpp:684

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

Definition at line 678 of file components.hpp.

678 { return "written_bytes"; }

◆ label_array()

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

Definition at line 696 of file components.hpp.

697  {
698  return std::vector<std::string>{ label(), "written_rate" };
699  }
static std::string label()
Definition: components.hpp:678

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

◆ record() [1/2]

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

Definition at line 716 of file components.hpp.

717  {
718  return value_type{ { get_bytes_written(), get_timestamp() } };
719  }
std::array< int64_t, 2 > value_type
Definition: components.hpp:672

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

◆ record() [2/2]

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

read the value from the cache

Definition at line 852 of file components.hpp.

853  {
854  return value_type{ { _cache.get_bytes_written(), get_timestamp() } };
855  }

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

◆ sample() [1/2]

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

sample a measurement

Definition at line 838 of file components.hpp.

839  {
840  std::get<0>(accum) = std::get<0>(value) =
841  std::max<int64_t>(std::get<0>(value), get_bytes_written());
842  }

◆ sample() [2/2]

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

sample a measurement from cached data

Definition at line 845 of file components.hpp.

846  {
847  std::get<0>(accum) = std::get<0>(value) =
848  std::max<int64_t>(std::get<0>(value), _cache.get_bytes_written());
849  }

◆ start() [1/2]

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

Definition at line 782 of file components.hpp.

782 { value = record(); }
static value_type record()
Definition: components.hpp:716

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

◆ start() [2/2]

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

start a measurement using the cached data

Definition at line 858 of file components.hpp.

858 { value = record(_cache); }

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

◆ stop() [1/2]

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

Definition at line 784 of file components.hpp.

785  {
786  using namespace tim::component::operators;
787  auto diff = (record() - value);
788  std::get<0>(diff) = std::abs(std::get<0>(diff));
789  accum += (value = diff);
790  }
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_bytes::stop ( const cache_type _cache)
inline

stop a measurement using the cached data

Definition at line 861 of file components.hpp.

862  {
863  using namespace tim::component::operators;
864  auto diff = (record(_cache) - value);
865  std::get<0>(diff) = std::abs(std::get<0>(diff));
866  accum += (value = diff);
867  }

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

◆ unit()

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

Definition at line 684 of file components.hpp.

685  {
686  return result_type{ { units::megabyte,
687  static_cast<double>(units::megabyte) / units::sec } };
688  }

◆ unit_array()

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

Definition at line 706 of file components.hpp.

706 { return unit(); }

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


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