Class for managing timers across the simulation.
More...
#include <TimerProfiler.h>
|
enum class | Displaymode { ALL
, ACTIVE
, NON_ZERO
, NONE
} |
|
|
| TimerProfiler () |
| Constructor of TimerProfiler. More...
|
|
void | readXML (XMLfileUnits &xmlconfig) |
| Read in XML configuration for TimerProfiler. More...
|
|
void | setDisplayMode (Displaymode mode) |
|
Displaymode | getDisplayMode () |
|
void | registerTimer (std::string timerName, std::vector< std::string > parentTimerNames, Timer *timer=nullptr, bool activate=true) |
| Adds a timer in the container. More...
|
|
Timer * | getTimer (std::string timerName) |
| Gets a pointer to the timer with name "timerName". More...
|
|
void | activateTimer (std::string timerName) |
| Activates the timer "timerName". More...
|
|
void | deactivateTimer (std::string timerName) |
| Deactivates the timer "timerName". More...
|
|
void | setSyncTimer (std::string timerName, bool sync) |
| Sets sync mode of the timer "timerName". More...
|
|
void | print (std::string timerName, std::string outputPrefix="") |
|
void | printTimers (std::string timerName=_baseTimerName, std::string outputPrefix="") |
| Prints time collected by timer "timerName" and the time from all of its descendants. More...
|
|
void | start (std::string timerName) |
| Starts the timer "timerName". More...
|
|
void | stop (std::string timerName) |
|
void | reset (std::string timerName) |
|
void | resetTimers (std::string timerName=_baseTimerName) |
| Resets the timer "timerName" and all of its descendants. More...
|
|
void | readInitialTimersFromFile (std::string fileName) |
| Sets up initial configuration of the timers during the simulation. More...
|
|
void | setOutputString (std::string timerName, std::string outputString) |
| Sets the output string for the timer output. More...
|
|
std::string | getOutputString (std::string timerName) |
|
double | getTime (std::string timerName) |
| Gets the time collected by timer "timerName". More...
|
|
void | incrementTimerTimestepCounter () |
| Increment the timestep-counter.
|
|
unsigned long | getNumElapsedIterations () const |
| get the number of iterations since the last resetting of all timers. More...
|
|
Class for managing timers across the simulation.
This class is a manager for all timers in the simulation. There should only be one instance of this class across the simulation. This class supports a hierarchical structure of the timers and can output the time of the timers in a more user-friendly manner
◆ TimerProfiler()
TimerProfiler::TimerProfiler |
( |
| ) |
|
Constructor of TimerProfiler.
The constructor creates a "virtual" base timer (named "_baseTimer"), which is the top of the timer hierarchy. All other inserted timers are sub-timers of this _baseTimer. Also reads and initializes all timers in the timer config-file.
◆ activateTimer()
void TimerProfiler::activateTimer |
( |
std::string |
timerName | ) |
|
Activates the timer "timerName".
- Parameters
-
timerName | The name of the timer to be activated |
◆ deactivateTimer()
void TimerProfiler::deactivateTimer |
( |
std::string |
timerName | ) |
|
Deactivates the timer "timerName".
Gets the output string for the timer output.
- Parameters
-
timerName | The name of the timer to be deactivated |
timerName | The name of the timer whose output string is requested |
- Returns
- The string to be displayed whenever the timer is printed
◆ getNumElapsedIterations()
unsigned long TimerProfiler::getNumElapsedIterations |
( |
| ) |
const |
|
inline |
get the number of iterations since the last resetting of all timers.
- Returns
- Number of iterations since last resetting of timers.
◆ getTime()
double TimerProfiler::getTime |
( |
std::string |
timerName | ) |
|
Gets the time collected by timer "timerName".
- Parameters
-
timerName | The name of the timer whose collected time is requested |
- Returns
- Time collected by timer "timerName"
◆ getTimer()
Timer * TimerProfiler::getTimer |
( |
std::string |
timerName | ) |
|
Gets a pointer to the timer with name "timerName".
- Parameters
-
timerName | The name of the requested timer |
- Returns
- A pointer to the requested timer or nullptr if the timer is not an actual timer
◆ printTimers()
void TimerProfiler::printTimers |
( |
std::string |
startingTimerName = _baseTimerName , |
|
|
std::string |
outputPrefix = "" |
|
) |
| |
Prints time collected by timer "timerName" and the time from all of its descendants.
- Parameters
-
timerName | The name of the timer from where to start the print; defaults to the base timer |
outputPrefix | String prefix for the hierarchical print |
◆ readInitialTimersFromFile()
void TimerProfiler::readInitialTimersFromFile |
( |
std::string |
fileName | ) |
|
Sets up initial configuration of the timers during the simulation.
Reads timers provided in the timer config-file and inserts them in the container, (de-)activates them and creates the hierarchical structure of the timers.
- Parameters
-
fileName | The name of the timer config-file |
◆ readXML()
Read in XML configuration for TimerProfiler.
The following xml object structure is handled by this method:
<programtimers>
<displaymode>all|active|non-zero|none</displaymode>
</programtimers>
Display mode explanation:
- all: display all registered timer
- active: display all active timers
- non-zero: display all timers which have non zero time
- none: do not display timers
◆ registerTimer()
void TimerProfiler::registerTimer |
( |
std::string |
timerName, |
|
|
std::vector< std::string > |
parentTimerNames, |
|
|
Timer * |
timer = nullptr , |
|
|
bool |
activate = true |
|
) |
| |
Adds a timer in the container.
- Parameters
-
timerName | The name of the timer to be added |
parentTimerNames | The names of the timers of which this timer is a sub-timer of |
timer | A pointer to the timer to be added in the container or nullptr if this is just a "virtual" timer ("manager" of timers) |
activate | Boolean variable indicating whether the timer should be active or not. All calls to an inactive timer will have no effect on it |
◆ resetTimers()
void TimerProfiler::resetTimers |
( |
std::string |
timerName = _baseTimerName | ) |
|
Resets the timer "timerName" and all of its descendants.
- Parameters
-
timerName | The name of the timer to be deactivated; defaults to the base timer |
◆ setOutputString()
void TimerProfiler::setOutputString |
( |
std::string |
timerName, |
|
|
std::string |
outputString |
|
) |
| |
Sets the output string for the timer output.
- Parameters
-
timerName | The name of the timer whose output string is to be modified |
outputString | The string to be displayed whenever the timer is printed |
◆ setSyncTimer()
void TimerProfiler::setSyncTimer |
( |
std::string |
timerName, |
|
|
bool |
sync |
|
) |
| |
Sets sync mode of the timer "timerName".
- Parameters
-
timerName | The name of the timer whose sync mode is to be set |
sync | Boolean variable indicating whether the timer should be synced or not |
◆ start()
void TimerProfiler::start |
( |
std::string |
timerName | ) |
|
Starts the timer "timerName".
- Parameters
-
timerName | The name of the timer to be started |
The documentation for this class was generated from the following files: