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

this struct extracts the absolute value of high-water mark of the resident set size (RSS) at start and stop points. RSS is current amount of memory in RAM. More...

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

+ Collaboration diagram for tim::component::current_peak_rss:

Public Types

using unit_type = std::pair< int64_t, int64_t >
 
using display_unit_type = std::pair< std::string, std::string >
 
using result_type = std::pair< double, double >
 
using this_type = current_peak_rss
 

Public Member Functions

void start ()
 
void stop ()
 
void start (const cache_type &_cache)
 
void stop (const cache_type &_cache)
 
std::string get_display () const
 
result_type get () const
 

Static Public Member Functions

static std::string label ()
 
static std::string description ()
 
static value_type record ()
 
static value_type record (const cache_type &_cache)
 
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 unit_type get_unit ()
 
static display_unit_type get_display_unit ()
 

Detailed Description

this struct extracts the absolute value of high-water mark of the resident set size (RSS) at start and stop points. RSS is current amount of memory in RAM.

Definition at line 571 of file components.hpp.

Member Typedef Documentation

◆ display_unit_type

using tim::component::current_peak_rss::display_unit_type = std::pair<std::string, std::string>

Definition at line 574 of file components.hpp.

◆ result_type

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

Definition at line 575 of file components.hpp.

◆ this_type

◆ unit_type

using tim::component::current_peak_rss::unit_type = std::pair<int64_t, int64_t>

Definition at line 573 of file components.hpp.

Member Function Documentation

◆ description()

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

Definition at line 579 of file components.hpp.

580  {
581  return "Absolute value of high-water mark of memory allocation in RAM";
582  }

◆ description_array()

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

Definition at line 663 of file components.hpp.

664  {
665  return std::vector<std::string>{ "Resident set size at start",
666  "Resident set size at stop" };
667  }

◆ display_unit()

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

Definition at line 659 of file components.hpp.

659 { return display_unit_type{ "MB", "MB" }; }
std::pair< std::string, std::string > display_unit_type
Definition: components.hpp:574

Referenced by get_display_unit().

◆ display_unit_array()

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

Definition at line 648 of file components.hpp.

649  {
650  return std::vector<std::string>{ get_display_unit().first,
651  get_display_unit().second };
652  }
static display_unit_type get_display_unit()
Definition: components.hpp:683

References get_display_unit().

◆ get()

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

Definition at line 635 of file components.hpp.

636  {
637  result_type data = base_type::load();
638  data.first /= get_unit().first;
639  data.second /= get_unit().second;
640  return data;
641  }
void load(Archive &ar, tim::node::graph< Tp > &d)
Definition: node.hpp:520
std::pair< double, double > result_type
Definition: components.hpp:575

References get_unit(), and tim::cereal::load().

Referenced by get_display().

◆ get_display()

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

Definition at line 609 of file components.hpp.

610  {
611  std::stringstream ss;
612  std::stringstream ssv;
613  std::stringstream ssr;
614  auto _prec = base_type::get_precision();
615  auto _width = base_type::get_width();
616  auto _flags = base_type::get_format_flags();
617  auto _disp = get_display_unit();
618 
619  auto _val = get();
620 
621  ssv.setf(_flags);
622  ssv << std::setw(_width) << std::setprecision(_prec) << std::get<0>(_val);
623  if(!std::get<0>(_disp).empty())
624  ssv << " " << std::get<0>(_disp);
625 
626  ssr.setf(_flags);
627  ssr << std::setw(_width) << std::setprecision(_prec) << std::get<1>(_val);
628  if(!std::get<1>(_disp).empty())
629  ssr << " " << std::get<1>(_disp);
630 
631  ss << ssv.str() << ", " << ssr.str();
632  return ss.str();
633  }

References get(), and get_display_unit().

◆ get_display_unit()

static display_unit_type tim::component::current_peak_rss::get_display_unit ( )
inlinestatic

Definition at line 683 of file components.hpp.

684  {
685  static display_unit_type _instance = this_type::display_unit();
686  static auto& _mem = _instance;
687 
688  if(settings::memory_units().length() > 0)
689  {
690  _mem.first = std::get<0>(units::get_memory_unit(settings::memory_units()));
691  _mem.second = std::get<0>(units::get_memory_unit(settings::memory_units()));
692  }
693 
694  return _mem;
695  }
std::tuple< std::string, int64_t > get_memory_unit(std::string _unit)
Definition: units.hpp:188
memory_units
Definition: settings.cpp:1351
static display_unit_type display_unit()
Definition: components.hpp:659

References display_unit(), tim::units::get_memory_unit(), and tim::memory_units.

Referenced by display_unit_array(), and get_display().

◆ get_unit()

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

Definition at line 669 of file components.hpp.

670  {
671  static auto _instance = this_type::unit();
672  static auto& _mem = _instance;
673 
674  if(settings::memory_units().length() > 0)
675  {
676  _mem.first = std::get<1>(units::get_memory_unit(settings::memory_units()));
677  _mem.second = std::get<1>(units::get_memory_unit(settings::memory_units()));
678  }
679 
680  return _mem;
681  }
static std::pair< double, double > unit()
Definition: components.hpp:643

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

Referenced by get().

◆ label()

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

Definition at line 578 of file components.hpp.

578 { return "current_peak_rss"; }

◆ label_array()

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

Definition at line 654 of file components.hpp.

655  {
656  return std::vector<std::string>{ "start peak rss", " stop peak rss" };
657  }

◆ record() [1/2]

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

Definition at line 584 of file components.hpp.

584 { return value_type{ get_peak_rss(), 0 }; }

Referenced by start(), and stop().

◆ record() [2/2]

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

Definition at line 595 of file components.hpp.

596  {
597  return value_type{ _cache.get_peak_rss(), 0 };
598  }

◆ start() [1/2]

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

Definition at line 586 of file components.hpp.

586 { value = record(); }

References record().

◆ start() [2/2]

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

Definition at line 600 of file components.hpp.

600 { value = record(_cache); }

References record().

◆ stop() [1/2]

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

Definition at line 588 of file components.hpp.

589  {
590  using namespace tim::component::operators;
591  value = value_type{ value.first, record().first };
592  accum = std::max(accum, value);
593  }
::tim::statistics< Tp > max(::tim::statistics< Tp > lhs, const Tp &rhs)
Definition: statistics.hpp:310

References record().

◆ stop() [2/2]

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

Definition at line 602 of file components.hpp.

603  {
604  value = value_type{ value.first, record(_cache).first };
605  accum = std::max(accum, value);
606  }

References record().

◆ unit()

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

Definition at line 643 of file components.hpp.

644  {
645  return std::pair<double, double>{ units::megabyte, units::megabyte };
646  }

Referenced by get_unit(), and unit_array().

◆ unit_array()

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

Definition at line 661 of file components.hpp.

661 { return unit(); }

References unit().


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