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::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
 
using storage_type = empty_storage
 
using base_type = void
 

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

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

Member Typedef Documentation

◆ base_type

using tim::component::empty_base::base_type = void
inherited

Definition at line 67 of file declaration.hpp.

◆ display_unit_type

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

Definition at line 566 of file components.hpp.

◆ result_type

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

Definition at line 567 of file components.hpp.

◆ storage_type

Definition at line 66 of file declaration.hpp.

◆ this_type

◆ unit_type

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

Definition at line 565 of file components.hpp.

Member Function Documentation

◆ description()

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

Definition at line 571 of file components.hpp.

572 {
573 return "Absolute value of high-water mark of memory allocation in RAM";
574 }

◆ description_array()

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

Definition at line 655 of file components.hpp.

656 {
657 return std::vector<std::string>{ "Resident set size at start",
658 "Resident set size at stop" };
659 }

◆ display_unit()

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

Definition at line 651 of file components.hpp.

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

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

641 {
642 return std::vector<std::string>{ get_display_unit().first,
643 get_display_unit().second };
644 }
static display_unit_type get_display_unit()
Definition: components.hpp:675

References get_display_unit().

◆ get()

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

Definition at line 627 of file components.hpp.

628 {
630 data.first /= get_unit().first;
631 data.second /= get_unit().second;
632 return data;
633 }
void load(Archive &ar, tim::node::graph< Tp > &d)
Definition: node.hpp:520
std::pair< double, double > result_type
Definition: components.hpp:567

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

602 {
603 std::stringstream ss;
604 std::stringstream ssv;
605 std::stringstream ssr;
606 auto _prec = base_type::get_precision();
607 auto _width = base_type::get_width();
608 auto _flags = base_type::get_format_flags();
609 auto _disp = get_display_unit();
610
611 auto _val = get();
612
613 ssv.setf(_flags);
614 ssv << std::setw(_width) << std::setprecision(_prec) << std::get<0>(_val);
615 if(!std::get<0>(_disp).empty())
616 ssv << " " << std::get<0>(_disp);
617
618 ssr.setf(_flags);
619 ssr << std::setw(_width) << std::setprecision(_prec) << std::get<1>(_val);
620 if(!std::get<1>(_disp).empty())
621 ssr << " " << std::get<1>(_disp);
622
623 ss << ssv.str() << ", " << ssr.str();
624 return ss.str();
625 }

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

676 {
677 static display_unit_type _instance = this_type::display_unit();
678 static auto& _mem = _instance;
679
680 if(settings::memory_units().length() > 0)
681 {
682 _mem.first = std::get<0>(units::get_memory_unit(settings::memory_units()));
683 _mem.second = std::get<0>(units::get_memory_unit(settings::memory_units()));
684 }
685
686 return _mem;
687 }
std::tuple< std::string, int64_t > get_memory_unit(std::string _unit)
Definition: units.hpp:188
memory_units
Definition: settings.cpp:1657
static display_unit_type display_unit()
Definition: components.hpp:651

References display_unit(), tim::units::get_memory_unit(), and tim::memory_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_unit()

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

Definition at line 661 of file components.hpp.

662 {
663 static auto _instance = this_type::unit();
664 static auto& _mem = _instance;
665
666 if(settings::memory_units().length() > 0)
667 {
668 _mem.first = std::get<1>(units::get_memory_unit(settings::memory_units()));
669 _mem.second = std::get<1>(units::get_memory_unit(settings::memory_units()));
670 }
671
672 return _mem;
673 }
static std::pair< double, double > unit()
Definition: components.hpp:635

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

570{ return "current_peak_rss"; }

◆ label_array()

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

Definition at line 646 of file components.hpp.

647 {
648 return std::vector<std::string>{ "start peak rss", " stop peak rss" };
649 }

◆ record() [1/2]

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

Definition at line 576 of file components.hpp.

576{ 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 587 of file components.hpp.

588 {
589 return value_type{ _cache.get_peak_rss(), 0 };
590 }

◆ start() [1/2]

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

Definition at line 578 of file components.hpp.

578{ value = record(); }

References record().

◆ start() [2/2]

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

Definition at line 592 of file components.hpp.

592{ value = record(_cache); }

References record().

◆ stop() [1/2]

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

Definition at line 580 of file components.hpp.

581 {
582 using namespace tim::component::operators;
583 value = value_type{ value.first, record().first };
584 accum = std::max(accum, value);
585 }
::tim::statistics< Tp > max(::tim::statistics< Tp > lhs, const Tp &rhs)
Definition: statistics.hpp:320

References std::max(), and record().

◆ stop() [2/2]

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

Definition at line 594 of file components.hpp.

595 {
596 value = value_type{ value.first, record(_cache).first };
597 accum = std::max(accum, value);
598 }

References std::max(), and record().

◆ unit()

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

Definition at line 635 of file components.hpp.

636 {
637 return std::pair<double, double>{ units::megabyte, units::megabyte };
638 }

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

653{ return unit(); }

References unit().


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