Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/classcasa_1_1Timer.html
Дата изменения: Unknown Дата индексирования: Mon Feb 14 20:10:21 2011 Кодировка: Поисковые слова: guide 8.0 |
measure the time it takes to execute parts of a program More...
#include <Timer.h>
Public Member Functions | |
Timer () | |
Construct a timer and set the mark ("mark()"). | |
void | mark () |
Set the timer mark -- i.e., start the clock ticking. | |
double | user () const |
Get the user time (in seconds) since last "mark()". | |
double | system () const |
Get the system time (in seconds) since last "mark()". | |
double | all () const |
Get the user+system time (in seconds) since last "mark()". | |
double | real () const |
Get the real time (in seconds) since last "mark()". | |
void | show () const |
Show real, user, system time (in seconds) on cout or a user supplied stream. | |
void | show (ostream &os) const |
void | show (const String &) const |
Show real, user, system time (in seconds) on cout or a user supplied stream preceeded by the string parameter. | |
void | show (ostream &os, const String &prefix) const |
double | user_usec () const |
Get the user time (in microseconds) since last "mark()". | |
double | system_usec () const |
Get the system time (in microseconds) since last "mark()". | |
double | all_usec () const |
Get the user+system time (in microseconds) since last "mark()". | |
Private Attributes | |
rusage | usage0 |
timeb | real0 |
measure the time it takes to execute parts of a program
Public interface
The Timer class provides an interface to system timing. It allows a C++ program to record the time between a reference point (mark) and now. This class uses the system time(2) interface to provide time resolution at either millisecond or microsecond granularity, depending upon operating system support and features. Since the time duration is stored in a 32-bit word, the maximum time period before rollover occurs is about 71 minutes.
Due to operating system dependencies, the accuracy of all member function results may not be as documented. For example some operating systems do not support timers with microsecond resolution. In those cases, the values returned are provided to the nearest millisecond or other unit of time as appropriate. See the Timer header file for system- specific notes.
Tip: This Timer class is based on the TI COOL library Timer class
Here's how to create a timer, start it (the 'mark' member function) and display a breakdown. Recall that
Timer timer; // the mark is set at construction time timer.mark(); // if you want to restart the clock ...do some calculation..\. cout << "user: " << timer.user () << endl; cout << "system: " << timer.system () << endl; cout << "real: " << timer.real () << endl;
add 'start' member function, a synonym for 'mark' but more comprehensible
Definition at line 127 of file Timer.h.
casa::Timer::Timer | ( | ) | [inline] |
double casa::Timer::all | ( | ) | const |
Get the user+system time (in seconds) since last "mark()".
double casa::Timer::all_usec | ( | ) | const |
Get the user+system time (in microseconds) since last "mark()".
void casa::Timer::mark | ( | ) |
Set the timer mark -- i.e., start the clock ticking.
Referenced by Timer().
double casa::Timer::real | ( | ) | const |
Get the real time (in seconds) since last "mark()".
void casa::Timer::show | ( | const String & | ) | const |
Show real, user, system time (in seconds) on cout or a user supplied stream preceeded by the string parameter.
void casa::Timer::show | ( | ostream & | os, | |
const String & | prefix | |||
) | const |
void casa::Timer::show | ( | ostream & | os | ) | const |
void casa::Timer::show | ( | ) | const |
Show real, user, system time (in seconds) on cout or a user supplied stream.
double casa::Timer::system | ( | ) | const |
Get the system time (in seconds) since last "mark()".
double casa::Timer::system_usec | ( | ) | const |
Get the system time (in microseconds) since last "mark()".
double casa::Timer::user | ( | ) | const |
Get the user time (in seconds) since last "mark()".
double casa::Timer::user_usec | ( | ) | const |
Get the user time (in microseconds) since last "mark()".
timeb casa::Timer::real0 [private] |
rusage casa::Timer::usage0 [private] |