HOPS
HOPS class reference
Public Member Functions | Static Public Member Functions | List of all members
hops::MHO_Profiler Class Reference

Class MHO_Profiler - uses the singleton pattern. More...

#include <MHO_Profiler.hh>

Public Member Functions

 MHO_Profiler (MHO_Profiler &&)=delete
 
 MHO_Profiler (MHO_Profiler const &)=delete
 
void AddEntry (int flag, uint64_t thread_id, std::string filename, int line_num, std::string func_name)
 Adds a profiling event to the internal list if not disabled. More...
 
void Disable ()
 Sets HOPS_COLOR_MSG to disabled state. More...
 
void DumpEvents ()
 Prints all stored events along with their details. More...
 
void Enable ()
 Sets the enabled state to true. More...
 
void GetEvents (std::vector< MHO_ProfileEvent > &events)
 Getter for events - at end of program, retrieve and utilize the profiler events. More...
 
bool IsEnabled () const
 Checks if the feature is enabled. More...
 
void Lock ()
 Acquires a lock using fMutex for thread synchronization. TODO we need to eliminate the need for locks...which sort of interferes with the objective of profiling. However, to do that we would probably need a lock free map implementation in order to map the thread_id's to a local index and push the events into a thread-specific vector so for now, mutex it is... More...
 
MHO_Profileroperator= (MHO_Profiler &&)=delete
 
MHO_Profileroperator= (MHO_Profiler const &)=delete
 
void Unlock ()
 Releases control of the mutex. More...
 

Static Public Member Functions

static MHO_ProfilerGetInstance ()
 provide public access to the only static instance More...
 

Detailed Description

Class MHO_Profiler - uses the singleton pattern.

class for running time/performance profiling when the profile is enabled, a section of code can be profiled by wrapping it between a call to profiler_start() and profiler_stop(), for example:

Author
J. Barrett - barre.nosp@m.ttj@.nosp@m.mit.e.nosp@m.du
Date
Sat Feb 10 11:17:05 2024 -0500

profiler_start(); function_to_profile(); profiler_stop();

Constructor & Destructor Documentation

◆ MHO_Profiler() [1/2]

hops::MHO_Profiler::MHO_Profiler ( MHO_Profiler const &  )
delete

◆ MHO_Profiler() [2/2]

hops::MHO_Profiler::MHO_Profiler ( MHO_Profiler &&  )
delete

Member Function Documentation

◆ AddEntry()

void hops::MHO_Profiler::AddEntry ( int  flag,
uint64_t  thread_id,
std::string  filename,
int  line_num,
std::string  func_name 
)

Adds a profiling event to the internal list if not disabled.

Parameters
flagA flag indicating the type of event (e.g., stop timer for this segment).
thread_idThe ID of the thread generating the event.
filenameThe truncated filename associated with the event.
line_numThe line number in the source code where the event occurred.
func_nameThe function name associated with the event.

◆ Disable()

void hops::MHO_Profiler::Disable ( )
inline

Sets HOPS_COLOR_MSG to disabled state.

◆ DumpEvents()

void hops::MHO_Profiler::DumpEvents ( )

Prints all stored events along with their details.

◆ Enable()

void hops::MHO_Profiler::Enable ( )
inline

Sets the enabled state to true.

◆ GetEvents()

void hops::MHO_Profiler::GetEvents ( std::vector< MHO_ProfileEvent > &  events)
inline

Getter for events - at end of program, retrieve and utilize the profiler events.

Parameters
eventsReference to std::vector<MHO_ProfileEvent to store retrieved events

◆ GetInstance()

static MHO_Profiler& hops::MHO_Profiler::GetInstance ( )
inlinestatic

provide public access to the only static instance

Returns
Reference to the singleton instance of MHO_Profiler
Note
This is a static function.

◆ IsEnabled()

bool hops::MHO_Profiler::IsEnabled ( ) const
inline

Checks if the feature is enabled.

Returns
True if enabled, false otherwise.

◆ Lock()

void hops::MHO_Profiler::Lock ( )
inline

Acquires a lock using fMutex for thread synchronization. TODO we need to eliminate the need for locks...which sort of interferes with the objective of profiling. However, to do that we would probably need a lock free map implementation in order to map the thread_id's to a local index and push the events into a thread-specific vector so for now, mutex it is...

◆ operator=() [1/2]

MHO_Profiler& hops::MHO_Profiler::operator= ( MHO_Profiler &&  )
delete

◆ operator=() [2/2]

MHO_Profiler& hops::MHO_Profiler::operator= ( MHO_Profiler const &  )
delete

◆ Unlock()

void hops::MHO_Profiler::Unlock ( )
inline

Releases control of the mutex.


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