Chaste Commit::1fd4e48e3990e67db148bc1bc4cf6991a0049d0c
GenericEventHandler< NUM_EVENTS, CONCRETE > Class Template Reference

#include <GenericEventHandler.hpp>

+ Inheritance diagram for GenericEventHandler< NUM_EVENTS, CONCRETE >:
+ Collaboration diagram for GenericEventHandler< NUM_EVENTS, CONCRETE >:

Static Public Member Functions

static GenericEventHandler< NUM_EVENTS, CONCRETE > * Instance ()
 
static void Reset ()
 
static void BeginEvent (unsigned event)
 
static void EndEvent (unsigned event)
 
static double GetElapsedTime (unsigned event)
 
static void Report ()
 
static void Headings ()
 
static void Enable ()
 
static void Disable ()
 
static bool IsEnabled ()
 

Protected Member Functions

 GenericEventHandler ()
 

Private Member Functions

double ConvertWallTimeToMilliseconds (double wallTime)
 
double ConvertWallTimeToSeconds (double wallTime)
 
void ResetImpl ()
 
void BeginEventImpl (unsigned event)
 
void EndEventImpl (unsigned event)
 
double GetElapsedTimeImpl (unsigned event)
 
void ReportImpl ()
 
void HeadingsImpl ()
 
void EnableImpl ()
 
void DisableImpl ()
 
bool IsEnabledImpl ()
 

Static Private Member Functions

static void MilliSleep (unsigned milliseconds)
 

Private Attributes

std::vector< doublemWallTime
 
std::vector< boolmHasBegun
 
bool mEnabled
 
bool mInUse
 

Friends

class TestGenericEventHandler
 
class TestCellBasedEventHandler
 
class TestHeartEventHandler
 

Detailed Description

template<unsigned NUM_EVENTS, class CONCRETE>
class GenericEventHandler< NUM_EVENTS, CONCRETE >

A generic base class providing the functionality for timing various events. Subclasses provide the event codes and names; see HeartEventHandler for an example.

Note: this class assume that, for any given concrete class, the last event represents the total time, and thus wraps all other events.

The methods in this class are not implemented separately as then they would not be inline, which could impact performance; we generally want timing routines to be very lightweight.

Definition at line 58 of file GenericEventHandler.hpp.

Constructor & Destructor Documentation

◆ GenericEventHandler()

Member Function Documentation

◆ BeginEvent()

template<unsigned NUM_EVENTS, class CONCRETE >
static void GenericEventHandler< NUM_EVENTS, CONCRETE >::BeginEvent ( unsigned  event)
inlinestatic

Record the start of an event.

Parameters
eventthe index of an event (this must be less than NUM_EVENTS)

Definition at line 133 of file GenericEventHandler.hpp.

References GenericEventHandler< NUM_EVENTS, CONCRETE >::Instance().

Referenced by GenericEventHandler< NUM_EVENTS, CONCRETE >::BeginEventImpl().

◆ BeginEventImpl()

◆ ConvertWallTimeToMilliseconds()

template<unsigned NUM_EVENTS, class CONCRETE >
double GenericEventHandler< NUM_EVENTS, CONCRETE >::ConvertWallTimeToMilliseconds ( double  wallTime)
inlineprivate

Convert a wall clock time to milliseconds.

Parameters
wallTimethe wall time
Returns
time in milliseconds.

Definition at line 93 of file GenericEventHandler.hpp.

Referenced by GenericEventHandler< NUM_EVENTS, CONCRETE >::GetElapsedTimeImpl().

◆ ConvertWallTimeToSeconds()

template<unsigned NUM_EVENTS, class CONCRETE >
double GenericEventHandler< NUM_EVENTS, CONCRETE >::ConvertWallTimeToSeconds ( double  wallTime)
inlineprivate

Convert a wall clock time to seconds. (Identity function in this implementation.)

Parameters
wallTimethe wall time
Returns
Time in seconds

Definition at line 104 of file GenericEventHandler.hpp.

Referenced by GenericEventHandler< NUM_EVENTS, CONCRETE >::ReportImpl().

◆ Disable()

template<unsigned NUM_EVENTS, class CONCRETE >
static void GenericEventHandler< NUM_EVENTS, CONCRETE >::Disable ( )
inlinestatic

Disable the event handler, so that event durations are no longer recorded.

Definition at line 190 of file GenericEventHandler.hpp.

References GenericEventHandler< NUM_EVENTS, CONCRETE >::Instance().

Referenced by GenericEventHandler< NUM_EVENTS, CONCRETE >::BeginEventImpl().

◆ DisableImpl()

template<unsigned NUM_EVENTS, class CONCRETE >
void GenericEventHandler< NUM_EVENTS, CONCRETE >::DisableImpl ( )
inlineprivate

Disable the event handler, so that event durations are no longer recorded.

Definition at line 461 of file GenericEventHandler.hpp.

References GenericEventHandler< NUM_EVENTS, CONCRETE >::mEnabled.

◆ Enable()

template<unsigned NUM_EVENTS, class CONCRETE >
static void GenericEventHandler< NUM_EVENTS, CONCRETE >::Enable ( )
inlinestatic

Enable the event handler so that it will record event durations.

Definition at line 184 of file GenericEventHandler.hpp.

References GenericEventHandler< NUM_EVENTS, CONCRETE >::Instance().

Referenced by GenericEventHandler< NUM_EVENTS, CONCRETE >::ResetImpl().

◆ EnableImpl()

template<unsigned NUM_EVENTS, class CONCRETE >
void GenericEventHandler< NUM_EVENTS, CONCRETE >::EnableImpl ( )
inlineprivate

Enable the event handler so that it will record event durations.

Definition at line 455 of file GenericEventHandler.hpp.

References GenericEventHandler< NUM_EVENTS, CONCRETE >::mEnabled.

◆ EndEvent()

template<unsigned NUM_EVENTS, class CONCRETE >
static void GenericEventHandler< NUM_EVENTS, CONCRETE >::EndEvent ( unsigned  event)
inlinestatic

Record the ending of an event.

Parameters
eventthe index of an event (this must be less than NUM_EVENTS)

Definition at line 143 of file GenericEventHandler.hpp.

References GenericEventHandler< NUM_EVENTS, CONCRETE >::Instance().

Referenced by GenericEventHandler< NUM_EVENTS, CONCRETE >::ReportImpl().

◆ EndEventImpl()

template<unsigned NUM_EVENTS, class CONCRETE >
void GenericEventHandler< NUM_EVENTS, CONCRETE >::EndEventImpl ( unsigned  event)
inlineprivate

Record the ending of an event.

Parameters
eventthe index of an event (this must be less than NUM_EVENTS)

Definition at line 277 of file GenericEventHandler.hpp.

References PetscTools::Barrier(), EXCEPTION, Timer::GetWallTime(), GenericEventHandler< NUM_EVENTS, CONCRETE >::mEnabled, GenericEventHandler< NUM_EVENTS, CONCRETE >::mHasBegun, and GenericEventHandler< NUM_EVENTS, CONCRETE >::mWallTime.

◆ GetElapsedTime()

template<unsigned NUM_EVENTS, class CONCRETE >
static double GenericEventHandler< NUM_EVENTS, CONCRETE >::GetElapsedTime ( unsigned  event)
inlinestatic
Returns
The time (in milliseconds) accounted so far to the given event.

Will automatically determine if the event is currently ongoing or not.

Parameters
eventthe index of an event (this must be less than NUM_EVENTS)

Definition at line 155 of file GenericEventHandler.hpp.

References GenericEventHandler< NUM_EVENTS, CONCRETE >::Instance().

◆ GetElapsedTimeImpl()

template<unsigned NUM_EVENTS, class CONCRETE >
double GenericEventHandler< NUM_EVENTS, CONCRETE >::GetElapsedTimeImpl ( unsigned  event)
inlineprivate
Returns
The time (in milliseconds) accounted so far to the given event.

Will automatically determine if the event is currently ongoing or not.

Parameters
eventthe index of an event (this must be less than NUM_EVENTS)

Definition at line 307 of file GenericEventHandler.hpp.

References GenericEventHandler< NUM_EVENTS, CONCRETE >::ConvertWallTimeToMilliseconds(), EXCEPTION, Timer::GetWallTime(), GenericEventHandler< NUM_EVENTS, CONCRETE >::mEnabled, GenericEventHandler< NUM_EVENTS, CONCRETE >::mHasBegun, and GenericEventHandler< NUM_EVENTS, CONCRETE >::mWallTime.

◆ Headings()

template<unsigned NUM_EVENTS, class CONCRETE >
static void GenericEventHandler< NUM_EVENTS, CONCRETE >::Headings ( )
inlinestatic

Output the headings for a report.

Definition at line 176 of file GenericEventHandler.hpp.

References GenericEventHandler< NUM_EVENTS, CONCRETE >::Instance().

◆ HeadingsImpl()

template<unsigned NUM_EVENTS, class CONCRETE >
void GenericEventHandler< NUM_EVENTS, CONCRETE >::HeadingsImpl ( )
inlineprivate

Output the headings for a report.

Definition at line 432 of file GenericEventHandler.hpp.

References PetscTools::AmMaster(), PetscTools::Barrier(), and PetscTools::IsParallel().

◆ Instance()

◆ IsEnabled()

template<unsigned NUM_EVENTS, class CONCRETE >
static bool GenericEventHandler< NUM_EVENTS, CONCRETE >::IsEnabled ( )
inlinestatic

Check whether the event handler is enabled.

Returns
true if enabled

Definition at line 198 of file GenericEventHandler.hpp.

References GenericEventHandler< NUM_EVENTS, CONCRETE >::Instance().

◆ IsEnabledImpl()

template<unsigned NUM_EVENTS, class CONCRETE >
bool GenericEventHandler< NUM_EVENTS, CONCRETE >::IsEnabledImpl ( )
inlineprivate

Check whether the event handler is enabled.

Returns
true if enabled

Definition at line 469 of file GenericEventHandler.hpp.

References GenericEventHandler< NUM_EVENTS, CONCRETE >::mEnabled.

◆ MilliSleep()

template<unsigned NUM_EVENTS, class CONCRETE >
static void GenericEventHandler< NUM_EVENTS, CONCRETE >::MilliSleep ( unsigned  milliseconds)
inlinestaticprivate

Sleep for a specified number of milliseconds. Used in testing. Ought to be more portable than sleep() or usleep().

Parameters
millisecondsminimum number of milliseconds for which to sleep (ought to be a multiple of 10)

Definition at line 78 of file GenericEventHandler.hpp.

References Timer::GetElapsedTime().

◆ Report()

template<unsigned NUM_EVENTS, class CONCRETE >
static void GenericEventHandler< NUM_EVENTS, CONCRETE >::Report ( )
inlinestatic

Print a report on the timed events and reset the handler.

Assumes all events have ended.

If there is a collection of processes then the report will include an average and maximum over all CPUs.

Definition at line 168 of file GenericEventHandler.hpp.

References GenericEventHandler< NUM_EVENTS, CONCRETE >::Instance().

◆ ReportImpl()

◆ Reset()

template<unsigned NUM_EVENTS, class CONCRETE >
static void GenericEventHandler< NUM_EVENTS, CONCRETE >::Reset ( )
inlinestatic

Reset the event handler - set all event durations to zero.

Definition at line 123 of file GenericEventHandler.hpp.

References GenericEventHandler< NUM_EVENTS, CONCRETE >::Instance().

Referenced by GenericEventHandler< NUM_EVENTS, CONCRETE >::ReportImpl().

◆ ResetImpl()

template<unsigned NUM_EVENTS, class CONCRETE >
void GenericEventHandler< NUM_EVENTS, CONCRETE >::ResetImpl ( )
inlineprivate

Friends And Related Symbol Documentation

◆ TestCellBasedEventHandler

template<unsigned NUM_EVENTS, class CONCRETE >
friend class TestCellBasedEventHandler
friend

Definition at line 61 of file GenericEventHandler.hpp.

◆ TestGenericEventHandler

template<unsigned NUM_EVENTS, class CONCRETE >
friend class TestGenericEventHandler
friend

Definition at line 60 of file GenericEventHandler.hpp.

◆ TestHeartEventHandler

template<unsigned NUM_EVENTS, class CONCRETE >
friend class TestHeartEventHandler
friend

Definition at line 62 of file GenericEventHandler.hpp.

Member Data Documentation

◆ mEnabled

◆ mHasBegun

◆ mInUse

◆ mWallTime


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