#ifndef SIMULATION_TIME_H #define SIMULATION_TIME_H #include #include #include // structure to measure a timing (stores begin and endpoint and the corresponding timespan) struct TimerEvent { std::chrono::time_point start; std::chrono::time_point stop; std::chrono::duration total_timespan; }; // class to time between a start and endpoint if the code has been compiled with // USE_TIMER = true, otherwise does nothing class SimulationTimer { public: // if first invocation of eventStartPoint with a specific event_name, adds a // TimerEvent at the time it was called; otherwise sets the value to // the time it has been invoked static void eventStartPoint(std::string event_name); // sets the endpoint in the TimerEvent struct to the time the function was called // the event_name has to match with an eventStartPoint invocation (not checked) // calculates the timedifference static void eventStopPoint(std::string event_name); // print a formatted string containing all event_names and their respective timing to stdout static void printDurations(); private: // map to store all event_names with their TimerEvent structs static std::map timed_events_; }; #endif /* SIMULATION_TIME_H */