Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
prof_time Class Reference

This utility class is to help in doing detailed profiling of code. It is uses the unix itimer system (see man getitimer). It is assumed that all 3 of the hi-res timers are running. They should be because JANA starts them all at program start up. More...

#include <prof_time.h>

Classes

class  time_diffs
 

Public Member Functions

 prof_time ()
 
virtual ~prof_time ()
 
void GetTime (void)
 
void TimeDiffNow (std::map< std::string, time_diffs > &prof_times, std::string what)
 
void TimeDiff (const prof_time &other_time, double &tdiff_real, double &tdiff_virt, double &tdiff_prof)
 

Public Attributes

struct itimerval real_tmr
 
struct itimerval virt_tmr
 
struct itimerval prof_tmr
 

Detailed Description

This utility class is to help in doing detailed profiling of code. It is uses the unix itimer system (see man getitimer). It is assumed that all 3 of the hi-res timers are running. They should be because JANA starts them all at program start up.

To use this, one would want to do something like the following:

Declare a container to hold timing info outside of evnt loop

static map<string, prof_time::time_diffs> prof_times;

Then, wrap the block of code you want to time with a prof_time variable and a call to its TimeDiffNow(...) method.

prof_time start_time;

<... do something ...>

start_time.TimeDiffNow(prof_times, "My code block 1");

Note that the current time is copied into the prof_time variable upon it's creation. To force the recording of a time at a position other than the line creating the object, call it's GetTime() method.

This system is designed to check all 3 timers. This might add a little more overhead than simply checking one timer, but at least this way this can be used for a broad range of purposes.

Definition at line 44 of file prof_time.h.

Constructor & Destructor Documentation

prof_time::prof_time ( )
inline

Definition at line 60 of file prof_time.h.

References GetTime().

virtual prof_time::~prof_time ( )
inlinevirtual

Definition at line 64 of file prof_time.h.

Member Function Documentation

void prof_time::GetTime ( void  )
inline

Definition at line 68 of file prof_time.h.

References prof_tmr, real_tmr, and virt_tmr.

Referenced by prof_time().

void prof_time::TimeDiff ( const prof_time other_time,
double &  tdiff_real,
double &  tdiff_virt,
double &  tdiff_prof 
)
inline

Definition at line 93 of file prof_time.h.

References prof_tmr, real_tmr, and virt_tmr.

Referenced by TimeDiffNow().

void prof_time::TimeDiffNow ( std::map< std::string, time_diffs > &  prof_times,
std::string  what 
)
inline

Member Data Documentation

struct itimerval prof_time::prof_tmr

Definition at line 117 of file prof_time.h.

Referenced by GetTime(), and TimeDiff().

struct itimerval prof_time::real_tmr

Definition at line 115 of file prof_time.h.

Referenced by GetTime(), and TimeDiff().

struct itimerval prof_time::virt_tmr

Definition at line 116 of file prof_time.h.

Referenced by GetTime(), and TimeDiff().


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