DUNE-FEM (unstable)
class with singleton instance managing timing for parts of program. More...
#include <dune/fem/misc/femtimer.hh>
Detailed Description
class with singleton instance managing timing for parts of program.
The simplest way of timing one line of code is to enclose it with the TIMEDEXECUTION
macro; the return value corresponds to the elapsed time, e.g., instead of writting
use
A more general usage is through the FemTimer class. The singleton instance can either be accessed through FemTimer::instance or through the reference femTimer. In order to use the timer, it is necessary to define the preprocessor variable FEMTIMER
or in the Makefile or in the main file before including the FemTimer header. If FEMTIMER
is not defined all methods of the class FemTimer with the exception of start
and stop
used for the TIMEDEXECUTION
macro are empty.
For computing the execution time of any part of a code, first get a unique id from the FemTimer by calling
where name
is a string used for output and subMarkers is an integer value greaten or equal to one, which can be used to time parts of the program. This can for example be done in the constructor of an operator. Remember to return the id to the FemTimer by calling
To start and stop the time keeping for a given program write
Execution time is summed up over all calls to start and stop. It is possible to pass an operation argument which changes this behavior; sum
and max
are implemented Using
the main timer (and all its subtimings) are set back to zero. Calling reset
without an argument resets all stored timers.
The use of sub timers works as shown in the following example:
Using FemTimer::print
(out,"test"); the result of all timings is printed to an ostream
. Subtimings are given relative to the main timing, i.e., first the main time is printed and following that the relative time used for each subpart of the algorithm. In the same manner the timing information can be stored in a file using FemTimer::printFile(filename)
. The first call opens the file and prints the string identifying each timing; each successive call prints one line containing all the timing information, again given first the main timing followed by the relative time used in each sub timing.
The documentation for this class was generated from the following file:
- dune/fem/misc/femtimer.hh