If used for logging, the ProcessTimerT object will print the string along with the CPU milliseconds elapsed (and additional memory resources used) since the object was constructed. The printing happens when the object is destroyed.
Nesting of ProcessTimerT is not allowed. The template class T should provide allow << to be done to it.
{ ProcessTimerT<ErrorLog::Streams> timer("doTask() took ", ErrorLogInfo ); doTask(); }will produce the output:
doTask() took 23 msecfor example, when the task is completed.
If not used for logging, the typical usage is to repeatedly call getElapsedTime or getCPU time.
Public Member Functions | |
ProcessTimerT (const std::string &message, T &os) | |
Constructor if you want logging. | |
ProcessTimerT () | |
Use this constructor if you don't require lifecycle logging. | |
TimeInterval | getElapsedTime () |
The elapsed time from the creation of this object. | |
TimeInterval | getCPUTime () |
The CPU time used by this process, its children and by the system on behalf of this process since the creation of this object. | |
int | getProgramSize () |
The memory currently being used by this program, in pages. | |
~ProcessTimerT () | |
If logging is required, logs the CPU time taken since construction. |
code::ProcessTimerT< T >::ProcessTimerT | ( | const std::string & | message, | |
T & | os | |||
) | [inline] |
Constructor if you want logging.
ProcessTimer timer("method() took ", std::cout )
code::ProcessTimerT< T >::ProcessTimerT | ( | ) | [inline] |
Use this constructor if you don't require lifecycle logging.
code::ProcessTimerT< T >::~ProcessTimerT | ( | ) | [inline] |
If logging is required, logs the CPU time taken since construction.
TimeInterval code::ProcessTimerT< T >::getCPUTime | ( | ) | [inline] |
The CPU time used by this process, its children and by the system on behalf of this process since the creation of this object.
TimeInterval code::ProcessTimerT< T >::getElapsedTime | ( | ) | [inline] |
The elapsed time from the creation of this object.
int code::ProcessTimerT< T >::getProgramSize | ( | ) | [inline] |
The memory currently being used by this program, in pages.