List of all members.
Detailed Description
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.
Usage
Use of this class is as you might expect by looking at the member functions:
Timer timer;
timer.start ();
...
timer.stop ();
std::cout << "Elapsed CPU time: " << timer() << " seconds.";
std::cout << "Elapsed wall time: " << timer.wall_time() << " seconds.";
timer.reset();
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.
- Note:
- 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.
- Author:
- G. Kanschat, W. Bangerth, M. Kronbichler
Definition at line 71 of file timer.h.
Constructor & Destructor Documentation
Constructor. Starts the timer at 0 sec.
Member Function Documentation
Re-start the timer at the point where it was stopped. This way a cumulative measurement of time is possible.
Referenced by restart().
Sets the current time as next starting time and return the elapsed time in seconds.
Stop the timer if necessary and reset the elapsed time to zero.
Referenced by restart().
| void Timer::restart |
( |
) |
[inline] |
| double Timer::operator() |
( |
) |
const |
Access to the current CPU time without disturbing time measurement. The elapsed time is returned in units of seconds.
| double Timer::wall_time |
( |
) |
const |
Access to the current wall time without disturbing time measurement. The elapsed time is returned in units of seconds.
Member Data Documentation
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.
Definition at line 176 of file timer.h.
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 199 of file timer.h.
Value of the wall time when start() was called the last time or when the object was created and no stop() was issued in between.
Definition at line 207 of file timer.h.
Accumulated time for all previous start()/stop() cycles. The time for the present cycle is not included.
Definition at line 214 of file timer.h.
Accumulated wall time for all previous start()/stop() cycles. The wall time for the present cycle is not included.
Definition at line 222 of file timer.h.
Store whether the timer is presently running.
Definition at line 228 of file timer.h.
Store whether the timer is presently running.
Definition at line 234 of file timer.h.
The documentation for this class was generated from the following file: