Timer Class Reference
Initialize the random-number-generator, using srand(time(NULL)).
More...
#include <tools.h>
List of all members.
Public Member Functions |
| Timer () |
| Default-Constructor.
|
void | start () |
| Starts the timer.
|
Timer & | stop () |
| Stops the timer.
|
| operator double () const |
| Gives the elapsed time as double.
|
Static Public Member Functions |
static void | print (ostream &out, double time) |
| Prints the elapsed time.
|
Private Attributes |
struct timeval | starttime |
| Stores the starttime of this Timer.
|
struct timeval | endtime |
| Stores the endtime of this Timer.
|
Friends |
ostream & | operator<< (ostream &out, Timer &w) |
| Output-operator.
|
Detailed Description
Initialize the random-number-generator, using srand(time(NULL)).
A class to stop processor time. Uses getrusage.
Definition at line 249 of file tools.h.
Constructor & Destructor Documentation
Timer::Timer |
( |
|
) |
[inline] |
Member Function Documentation
Starts the timer.
Calls getrusage to set starttime.
- See also:
- stop()
Stops the timer.
Calls getrusage to set endtime.
- Returns:
- This Timer, so you can write "out << w.stop();" to print the time, which is used since this Timer was started.
- See also:
- start()
Timer::operator double |
( |
|
) |
const |
Gives the elapsed time as double.
- Returns:
- The time-difference between starttime and endtime in seconds with a precision of E-6.
static void Timer::print |
( |
ostream & |
out, |
|
|
double |
time | |
|
) |
| | [static] |
Prints the elapsed time.
Prints the time-difference endtime-starttime in the format hour:minute:sec, where sec is printed with a precision of E-3 (milliseconds). You should have set the endtime by a call to stop().
- Parameters:
-
| out | The ostream to print to. |
Friends And Related Function Documentation
ostream& operator<< |
( |
ostream & |
out, |
|
|
Timer & |
w | |
|
) |
| | [friend] |
Output-operator.
Calls print.
- Parameters:
-
| out | The ostream to print to. |
| w | The Timer to print. |
- See also:
- print(ostream&)
Definition at line 256 of file tools.h.
Member Data Documentation
Stores the starttime of this Timer.
Definition at line 265 of file tools.h.
The documentation for this class was generated from the following file: