Timer Class Reference

A class to stop processor time. More...

#include <tools.h>

List of all members.

Public Member Functions

 Timer ()
 Default-Constructor.
void start ()
 Starts the timer.
Timerstop ()
 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

timeval starttime
 Stores the starttime of this Timer.
timeval endtime
 Stores the endtime of this Timer.

Friends

ostream & operator<< (ostream &out, Timer &w)
 Output-operator.


Detailed Description

A class to stop processor time.

Uses getrusage.

Definition at line 249 of file tools.h.


Constructor & Destructor Documentation

Timer::Timer (  )  [inline]

Default-Constructor.

Calls start().

See also:
start()

Definition at line 278 of file tools.h.

References start().


Member Function Documentation

void Timer::start (  ) 

Starts the timer.

Calls getrusage to set starttime.

See also:
stop()

Referenced by Timer().

Timer& Timer::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

struct timeval Timer::starttime [private]

Stores the starttime of this Timer.

Definition at line 265 of file tools.h.

struct timeval Timer::endtime [private]

Stores the endtime of this Timer.

Definition at line 268 of file tools.h.


The documentation for this class was generated from the following file:
Generated on Mon Oct 20 03:12:50 2008 for LaGO by  doxygen 1.4.7