![]() |
Chaste Commit::333233612e3dcc941d260418acd7b5ccdc30390e
|
#include <GenericEventHandler.hpp>
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< double > | mWallTime |
std::vector< bool > | mHasBegun |
bool | mEnabled |
bool | mInUse |
Friends | |
class | TestGenericEventHandler |
class | TestCellBasedEventHandler |
class | TestHeartEventHandler |
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.
|
inlineprotected |
Default constructor.
Definition at line 208 of file GenericEventHandler.hpp.
References GenericEventHandler< NUM_EVENTS, CONCRETE >::mEnabled, GenericEventHandler< NUM_EVENTS, CONCRETE >::mHasBegun, GenericEventHandler< NUM_EVENTS, CONCRETE >::mInUse, and GenericEventHandler< NUM_EVENTS, CONCRETE >::mWallTime.
|
inlinestatic |
Record the start of an event.
event | the 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().
|
inlineprivate |
Record the start of an event.
event | the index of an event (this must be less than NUM_EVENTS) |
Definition at line 237 of file GenericEventHandler.hpp.
References PetscTools::Barrier(), GenericEventHandler< NUM_EVENTS, CONCRETE >::BeginEvent(), GenericEventHandler< NUM_EVENTS, CONCRETE >::Disable(), Timer::GetWallTime(), GenericEventHandler< NUM_EVENTS, CONCRETE >::mEnabled, GenericEventHandler< NUM_EVENTS, CONCRETE >::mHasBegun, GenericEventHandler< NUM_EVENTS, CONCRETE >::mInUse, and GenericEventHandler< NUM_EVENTS, CONCRETE >::mWallTime.
|
inlineprivate |
Convert a wall clock time to milliseconds.
wallTime | the wall time |
Definition at line 93 of file GenericEventHandler.hpp.
Referenced by GenericEventHandler< NUM_EVENTS, CONCRETE >::GetElapsedTimeImpl().
|
inlineprivate |
Convert a wall clock time to seconds. (Identity function in this implementation.)
wallTime | the wall time |
Definition at line 104 of file GenericEventHandler.hpp.
Referenced by GenericEventHandler< NUM_EVENTS, CONCRETE >::ReportImpl().
|
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().
|
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.
|
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().
|
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.
|
inlinestatic |
Record the ending of an event.
event | the 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().
|
inlineprivate |
Record the ending of an event.
event | the 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.
|
inlinestatic |
Will automatically determine if the event is currently ongoing or not.
event | the 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().
|
inlineprivate |
Will automatically determine if the event is currently ongoing or not.
event | the 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.
|
inlinestatic |
Output the headings for a report.
Definition at line 176 of file GenericEventHandler.hpp.
References GenericEventHandler< NUM_EVENTS, CONCRETE >::Instance().
|
inlineprivate |
Output the headings for a report.
Definition at line 432 of file GenericEventHandler.hpp.
References PetscTools::AmMaster(), PetscTools::Barrier(), and PetscTools::IsParallel().
|
inlinestatic |
Definition at line 114 of file GenericEventHandler.hpp.
Referenced by GenericEventHandler< NUM_EVENTS, CONCRETE >::BeginEvent(), GenericEventHandler< NUM_EVENTS, CONCRETE >::Disable(), GenericEventHandler< NUM_EVENTS, CONCRETE >::Enable(), GenericEventHandler< NUM_EVENTS, CONCRETE >::EndEvent(), GenericEventHandler< NUM_EVENTS, CONCRETE >::GetElapsedTime(), GenericEventHandler< NUM_EVENTS, CONCRETE >::Headings(), GenericEventHandler< NUM_EVENTS, CONCRETE >::IsEnabled(), GenericEventHandler< NUM_EVENTS, CONCRETE >::Report(), and GenericEventHandler< NUM_EVENTS, CONCRETE >::Reset().
|
inlinestatic |
Check whether the event handler is enabled.
Definition at line 198 of file GenericEventHandler.hpp.
References GenericEventHandler< NUM_EVENTS, CONCRETE >::Instance().
|
inlineprivate |
Check whether the event handler is enabled.
Definition at line 469 of file GenericEventHandler.hpp.
References GenericEventHandler< NUM_EVENTS, CONCRETE >::mEnabled.
|
inlinestaticprivate |
Sleep for a specified number of milliseconds. Used in testing. Ought to be more portable than sleep() or usleep().
milliseconds | minimum 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().
|
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().
|
inlineprivate |
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 334 of file GenericEventHandler.hpp.
References PetscTools::AmMaster(), PetscTools::Barrier(), PetscTools::BeginRoundRobin(), GenericEventHandler< NUM_EVENTS, CONCRETE >::ConvertWallTimeToSeconds(), GenericEventHandler< NUM_EVENTS, CONCRETE >::EndEvent(), PetscTools::EndRoundRobin(), EXCEPTION, PetscTools::GetMyRank(), PetscTools::GetNumProcs(), PetscTools::GetWorld(), PetscTools::IsIsolated(), PetscTools::IsParallel(), GenericEventHandler< NUM_EVENTS, CONCRETE >::mEnabled, GenericEventHandler< NUM_EVENTS, CONCRETE >::mHasBegun, GenericEventHandler< NUM_EVENTS, CONCRETE >::mInUse, GenericEventHandler< NUM_EVENTS, CONCRETE >::mWallTime, and 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().
|
inlineprivate |
Reset the event handler - set all event durations to zero.
Definition at line 221 of file GenericEventHandler.hpp.
References GenericEventHandler< NUM_EVENTS, CONCRETE >::Enable(), GenericEventHandler< NUM_EVENTS, CONCRETE >::mHasBegun, GenericEventHandler< NUM_EVENTS, CONCRETE >::mInUse, and GenericEventHandler< NUM_EVENTS, CONCRETE >::mWallTime.
|
friend |
Definition at line 61 of file GenericEventHandler.hpp.
|
friend |
Definition at line 60 of file GenericEventHandler.hpp.
|
friend |
Definition at line 62 of file GenericEventHandler.hpp.
|
private |
Whether the event handler is recording event times
Definition at line 68 of file GenericEventHandler.hpp.
Referenced by GenericEventHandler< NUM_EVENTS, CONCRETE >::GenericEventHandler(), GenericEventHandler< NUM_EVENTS, CONCRETE >::BeginEventImpl(), GenericEventHandler< NUM_EVENTS, CONCRETE >::DisableImpl(), GenericEventHandler< NUM_EVENTS, CONCRETE >::EnableImpl(), GenericEventHandler< NUM_EVENTS, CONCRETE >::EndEventImpl(), GenericEventHandler< NUM_EVENTS, CONCRETE >::GetElapsedTimeImpl(), GenericEventHandler< NUM_EVENTS, CONCRETE >::IsEnabledImpl(), and GenericEventHandler< NUM_EVENTS, CONCRETE >::ReportImpl().
|
private |
Whether each event is in progress
Definition at line 67 of file GenericEventHandler.hpp.
Referenced by GenericEventHandler< NUM_EVENTS, CONCRETE >::GenericEventHandler(), GenericEventHandler< NUM_EVENTS, CONCRETE >::BeginEventImpl(), GenericEventHandler< NUM_EVENTS, CONCRETE >::EndEventImpl(), GenericEventHandler< NUM_EVENTS, CONCRETE >::GetElapsedTimeImpl(), GenericEventHandler< NUM_EVENTS, CONCRETE >::ReportImpl(), and GenericEventHandler< NUM_EVENTS, CONCRETE >::ResetImpl().
|
private |
Determines if any of the event have begun
Definition at line 69 of file GenericEventHandler.hpp.
Referenced by GenericEventHandler< NUM_EVENTS, CONCRETE >::GenericEventHandler(), GenericEventHandler< NUM_EVENTS, CONCRETE >::BeginEventImpl(), GenericEventHandler< NUM_EVENTS, CONCRETE >::ReportImpl(), and GenericEventHandler< NUM_EVENTS, CONCRETE >::ResetImpl().
|
private |
Wall time assigned to each event
Definition at line 66 of file GenericEventHandler.hpp.
Referenced by GenericEventHandler< NUM_EVENTS, CONCRETE >::GenericEventHandler(), GenericEventHandler< NUM_EVENTS, CONCRETE >::BeginEventImpl(), GenericEventHandler< NUM_EVENTS, CONCRETE >::EndEventImpl(), GenericEventHandler< NUM_EVENTS, CONCRETE >::GetElapsedTimeImpl(), GenericEventHandler< NUM_EVENTS, CONCRETE >::ReportImpl(), and GenericEventHandler< NUM_EVENTS, CONCRETE >::ResetImpl().