This is a very simple class which provides information about both the CPU time and the wallclock time elapsed since the timer was started last time. Information is retrieved from the system on the basis of clock cycles since last time the computer was booted for the CPU time. The wall time is based on the system clock accessed by
gettimeofday, with a typical accuracy of 0.01 ms on linux systems.
Use of this class is as you might expect by looking at the member functions:
std::cout << "Elapsed CPU time: " << timer() << " seconds.";
std::cout << "Elapsed wall time: "
() << " seconds."
Alternatively, you can also restart the timer instead of resetting it. The times between successive calls to start() / stop() will then be accumulated. The usage of this class is also explained in the step-28, step-29 and step-30 tutorial programs.
- Implementation of this class is system dependent. In case multithreaded routines (matrix-vector products, error estimators, etc.) are used, the CPU time is accumulated from all the children.
- G. Kanschat, W. Bangerth, M. Kronbichler
Definition at line 76 of file timer.h.
Constructor that takes an MPI communicator as input. A timer constructed this way will sum up the CPU times over all processors in the MPI network when requested by the operator ().
Starts the timer at 0 sec.
sync_wall_time is true, the wall time is synchronized between all CPUs using a MPI_Barrier() and a collective operation. Note that this only works if you stop() the timer before querying for the wall time. The time for the MPI operations are not included in the timing but may slow down your program.
This constructor is only available if the deal.II compiler is an MPI compiler.
Definition at line 71 of file timer.cc.
Similar to start_time, but needed for children threads in multithread mode. Value of the user time when start() was called the last time or when the object was created and no stop() was issued in between.
For some reason (error in operating system?) the function call
getrusage(RUSAGE_CHILDREN,.) gives always 0 (at least on Solaris7). Hence the Timer class still does not yet work for multithreading mode.
Definition at line 179 of file timer.h.