36#ifndef GENERICEVENTHANDLER_HPP_
37#define GENERICEVENTHANDLER_HPP_
57template <
unsigned NUM_EVENTS,
class CONCRETE>
60 friend class TestGenericEventHandler;
61 friend class TestCellBasedEventHandler;
62 friend class TestHeartEventHandler;
95 return wallTime*1000.0;
116 static CONCRETE inst;
223 for (
unsigned event=0;
event<NUM_EVENTS;
event++)
243#ifdef CHASTE_EVENT_BARRIERS
247 assert(
event<NUM_EVENTS);
249 if (
event != NUM_EVENTS-1)
260 msg +=
"The event associated with the counter for '";
261 msg += CONCRETE::EventName[
event];
262 msg +=
"' had already begun when BeginEvent was called.";
263 std::cerr << msg << std::endl << std::flush;
279 assert(
event<NUM_EVENTS);
284#ifdef CHASTE_EVENT_BARRIERS
290 msg +=
"Error: The event associated with the counter for '";
291 msg += CONCRETE::EventName[
event];
292 msg +=
"' had not begun when EndEvent was called.";
309 assert(
event<NUM_EVENTS);
312 EXCEPTION(
"Asked to report on a disabled event handler. Check for contributory errors above.");
338 EXCEPTION(
"Asked to report on a disabled event handler. Check for contributory errors above.");
342 EXCEPTION(
"Asked to report on an event handler which is set to zero.");
345 for (
unsigned event=0;
event<NUM_EVENTS;
event++)
353 const unsigned top_event = NUM_EVENTS-1;
358 if (total > 999999.0)
362 else if (total > 9999.0)
379 for (
unsigned event=0;
event<NUM_EVENTS;
event++)
382 printf(format, secs);
383 printf(
"(%3.0f%%) ", total == 0.0 ? 0.0 : (secs/total*100.0));
385 std::cout <<
"(seconds) \n";
392 double total_cpu_time[NUM_EVENTS];
398 for (
unsigned event=0;
event<NUM_EVENTS;
event++)
402 printf(
"(%3.0f%%) ", total == 0.0 ? 0.0 : (secs/total*100.0));
404 std::cout <<
"(seconds) \n";
407 double max_cpu_time[NUM_EVENTS];
413 for (
unsigned event=0;
event<NUM_EVENTS;
event++)
416 printf(format, secs);
417 printf(
"(%3.0f%%) ", total == 0.0 ? 0.0 : (secs/total*100.0));
419 std::cout <<
"(seconds) \n";
445 for (
unsigned event=0;
event<NUM_EVENTS;
event++)
447 printf(
"%15s%2s", CONCRETE::EventName[
event],
"");
#define EXCEPTION(message)
static double GetElapsedTime(unsigned event)
void BeginEventImpl(unsigned event)
double ConvertWallTimeToMilliseconds(double wallTime)
static void BeginEvent(unsigned event)
std::vector< bool > mHasBegun
static void MilliSleep(unsigned milliseconds)
double GetElapsedTimeImpl(unsigned event)
void EndEventImpl(unsigned event)
std::vector< double > mWallTime
double ConvertWallTimeToSeconds(double wallTime)
static GenericEventHandler< NUM_EVENTS, CONCRETE > * Instance()
static void EndEvent(unsigned event)
static double GetWallTime()
static double GetElapsedTime()