Navigation: Up, Table of Contents, Bibliography, Index, Title Page

A Timer for User-Process Time (CGAL_Timer)

Definition

A timer t of type CGAL_Timer is an object with a state. It is either running or it is stopped. The state is controlled with t.start() and t.stop() . The timer counts the time elapsed since its creation or last reset. It counts only the time where it is in the running state. The time information is given in seconds.

#include <CGAL/Timer.h>

Creation

CGAL_Timer t;
state is stopped.

Operations

void t.start ()
Precondition: state is stopped.
void t.stop ()
Precondition: state is running.
void t.reset () reset timer to zero. The state is unaffected.
bool t.is_running () true if the current state is running.
double t.time () user process time in seconds.
int t.intervals () number of start/stop-intervals since the last reset.
double t.precision () smallest possible time step in seconds.
double t.max () maximal representable time in seconds.

Implementation

The timer class is based in the C function clock(...) which measures the user and system times of the current process and its subprocesses. The time granularity is reasonable fine with currently 10 ms on IRIX and Solaris. However the counter wraps around after only about 36 minutes. On Solaris machines the man page states that the timer could fail. In that case an error message is printed and the program aborted.


Next: Class declaration of CGAL_Real_timer
Navigation: Up, Table of Contents, Bibliography, Index, Title Page
The CGAL Project. 22 January 1999.