Tools.h++ Class Reference

Table Of Contents
Example
This example prints out the amount of CPU time used while looping for 5 seconds (as measured
using class RWTime).
#include <rw/timer.h>
#include <rw/rwtime.h>
#include <rw/rstream.h>
main()
{RWTimer t;
t.start(); // Start the timer
RWTime start;
start.now(); // Record starting time
// Loop for 5 seconds:
for (RWTime current; current.seconds() - start.seconds() < 5;
current = RWTime::now())
{;}
t.stop(); // Stop the timer
cout << t.elapsedTime() << endl;
return 0;
}
Program output (exact value may differ):
5.054945
Public Constructor
RWTimer();
Constructs a new timer. The timer will not start running until start() is called.
Public Member Functions
double
elapsedTime() const;
Returns the amount of (CPU) time that has accumulated while the timer was in the
running state.
void
reset();