MAST3
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
MAST::Utility::PerformanceLogging Class Reference

Detailed Description

Definition at line 34 of file perf_log.hpp.

#include <perf_log.hpp>

Classes

class  Event
 
struct  EventData
 

Public Types

using map_type = std::map< std::string, MAST::Utility::PerformanceLogging::EventData >
 
using stack_type = std::stack< MAST::Utility::PerformanceLogging::Event >
 

Public Member Functions

 PerformanceLogging ()
 
 ~PerformanceLogging ()
 
void start_event (const std::string &nm)
 
void stop_event (const std::string &nm)
 

Protected Member Functions

map_type::iterator _get_event_data (const std::string &nm)
 

Protected Attributes

stack_type _event_stack
 
map_type _event_time
 

Member Typedef Documentation

◆ map_type

◆ stack_type

Constructor & Destructor Documentation

◆ PerformanceLogging()

MAST::Utility::PerformanceLogging::PerformanceLogging ( )

◆ ~PerformanceLogging()

MAST::Utility::PerformanceLogging::~PerformanceLogging ( )

Member Function Documentation

◆ _get_event_data()

map_type::iterator MAST::Utility::PerformanceLogging::_get_event_data ( const std::string &  nm)
inlineprotected

Definition at line 133 of file perf_log.hpp.

133  {
134 
135  map_type::iterator
136  it = _event_time.find(nm),
137  end = _event_time.end();
138 
139  if (it == end)
140  it = _event_time.insert(std::make_pair(nm, MAST::Utility::PerformanceLogging::EventData())).first;
141 
142  return it;
143  }

◆ start_event()

void MAST::Utility::PerformanceLogging::start_event ( const std::string &  nm)
inline

Definition at line 102 of file perf_log.hpp.

102  {
103 
104  map_type::iterator it = _get_event_data(nm);
106  }
map_type::iterator _get_event_data(const std::string &nm)
Definition: perf_log.hpp:133

◆ stop_event()

void MAST::Utility::PerformanceLogging::stop_event ( const std::string &  nm)
inline

Definition at line 108 of file perf_log.hpp.

108  {
109 
110 
111  // the object cannot be empty
112  Assert1(!_event_stack.empty(), !_event_stack.empty(),
113  "Empty event stack");
114 
116  v = _event_stack.top();
117 
118  // make sure that the top object has the same name as provided here
119  Assert0(nm == v.name(),
120  "Name provided must match as the last started event.");
121 
122  map_type::iterator it = _get_event_data(nm);
123  it->second.ncalls++;
124  it->second.sys += v.get_sys_time();
125  it->second.user += v.get_user_time();
126 
127  _event_stack.pop();
128  }
#define Assert1(cond, v1, msg)
Definition: exceptions.hpp:143
#define Assert0(cond, msg)
Definition: exceptions.hpp:134
map_type::iterator _get_event_data(const std::string &nm)
Definition: perf_log.hpp:133

Member Data Documentation

◆ _event_stack

stack_type MAST::Utility::PerformanceLogging::_event_stack
protected

Definition at line 145 of file perf_log.hpp.

◆ _event_time

map_type MAST::Utility::PerformanceLogging::_event_time
protected

Definition at line 146 of file perf_log.hpp.


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