OWLTimer

Synopsis

#include <owl/timer.h>
OWLTimer timer;

Description

This class can measure elapsed CPU user and system times. The timer has two states: running and stopped. The timer is put into the "running" state by calling member function start(). It is put into the "stopped" state by calling stop(). In addition the timer measures the total amount of time spent in the "running" state.
 

Example

This example prints out the amount of CPU time used while sleeping for 5 seconds.

#include <unistd.h>
#include <owl/timer.h>

main()
{
  OWLTimer t;
  t.start();                 // Start the timer

  OWLTime start( 0 );        // Record starting time

  // Sleep for 5 seconds:
  sleep( 5 );

  t.stop();                  // Stop the timer

  cout << t.userTime() << endl;
  cout << t.systemTime() << endl;
  cout << t.totalTime() << endl;
  return 0;
}

Program output (exact value may differ):

0
0
4.994945

Public Constructor

OWLTimer();

Public Member Functions void

reset();

     Resets (and stops) the timer.
void
start();
void
stop();
double
systemTime() const;
double
totalTime() const;
double
userTime() const;