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::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
 
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 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...
 
template<typename... Args>
static opaque get_opaque (Args &&...)
 

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

◆ storage_type

Definition at line 66 of file declaration.hpp.

◆ this_type

◆ unit_type

◆ value_type

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

Definition at line 671 of file components.hpp.

Member Function Documentation

◆ description()

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

Definition at line 678 of file components.hpp.

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

◆ description_array()

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

Definition at line 707 of file components.hpp.

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

◆ display_unit()

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

Definition at line 700 of file components.hpp.

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

Referenced by get_display_unit().

◆ display_unit_array()

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

Definition at line 689 of file components.hpp.

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

References get_display_unit().

◆ get()

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

Definition at line 755 of file components.hpp.

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

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

Referenced by get_display().

◆ get_display()

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

Definition at line 728 of file components.hpp.

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

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

Definition at line 814 of file components.hpp.

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

Definition at line 713 of file components.hpp.

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

Referenced by record().

◆ get_timing_unit()

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

Definition at line 720 of file components.hpp.

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

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

Referenced by get().

◆ get_unit()

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

Definition at line 791 of file components.hpp.

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

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

Definition at line 677 of file components.hpp.

677{ return "written_bytes"; }

Referenced by label_array().

◆ label_array()

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

Definition at line 695 of file components.hpp.

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

References label().

◆ record() [1/2]

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

Definition at line 715 of file components.hpp.

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

References get_timestamp().

Referenced by start(), and stop().

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

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

References get_timestamp().

◆ sample() [1/2]

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

sample a measurement

Definition at line 837 of file components.hpp.

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

◆ sample() [2/2]

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

sample a measurement from cached data

Definition at line 844 of file components.hpp.

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

◆ start() [1/2]

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

Definition at line 781 of file components.hpp.

781{ value = record(); }
static value_type record()
Definition: components.hpp:715

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

857{ value = record(_cache); }

References record().

◆ stop() [1/2]

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

Definition at line 783 of file components.hpp.

784 {
785 using namespace tim::component::operators;
786 auto diff = (record() - value);
787 std::get<0>(diff) = std::abs(std::get<0>(diff));
788 accum += (value = diff);
789 }
type_list abs(type_list<>)
Definition: fwd.hpp:405

References tim::math::abs, and 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 860 of file components.hpp.

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

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

◆ unit()

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

Definition at line 683 of file components.hpp.

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

Referenced by get_unit(), and unit_array().

◆ unit_array()

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

Definition at line 705 of file components.hpp.

705{ return unit(); }

References unit().


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