Class MHO_Profiler - uses the singleton pattern.
More...
#include <MHO_Profiler.hh>
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();
◆ MHO_Profiler() [1/2]
◆ MHO_Profiler() [2/2]
◆ 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
-
flag | A flag indicating the type of event (e.g., stop timer for this segment). |
thread_id | The ID of the thread generating the event. |
filename | The truncated filename associated with the event. |
line_num | The line number in the source code where the event occurred. |
func_name | The 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()
Getter for events - at end of program, retrieve and utilize the profiler events.
- Parameters
-
◆ GetInstance()
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]
◆ operator=() [2/2]
◆ Unlock()
void hops::MHO_Profiler::Unlock |
( |
| ) |
|
|
inline |
Releases control of the mutex.
The documentation for this class was generated from the following files: