Timer Class Reference

#include <timer.h>

List of all members.

Public Types

typedef struct timeval value_t

Public Member Functions

 Timer (bool startnow=true)
 ~Timer ()
void start ()
void stop ()
void reset (void)
double operator() (void) const
double time_since_start (void) const

Detailed Description

Simple timer class.

This class allows you to time things, for runtime statistics and the like. The simplest usage pattern is illustrated by the following example:

    Timer mytimer;                // automatically starts upon construction
    ...do stuff
    float t = mytimer();          // seconds elapsed since start

    Timer another (false);        // false means don't start ticking yet
    another.start ();             // start ticking now
    another.stop ();              // stop ticking
    another.start ();             // start again where we left off
    another.stop ();
    another.reset ();             // reset to zero time again

Constructor & Destructor Documentation

Timer::Timer ( bool  startnow = true  )  [inline]

Constructor -- reset at zero, and start timing unless optional 'startnow' argument is false.

Timer::~Timer (  )  [inline]

Destructor.


Member Function Documentation

double Timer::operator() ( void   )  const [inline]

Operator () returns the elapsed time so far, including both the currently-ticking clock as well as any previously elapsed time.

void Timer::reset ( void   )  [inline]

Reset at zero and stop ticking.

void Timer::start (  )  [inline]

Start ticking, or restart if we have stopped.

void Timer::stop (  )  [inline]

Stop ticking. Any elapsed time will be saved even though we aren't currently ticking.

double Timer::time_since_start ( void   )  const [inline]

Return just the time since we called start(), not any elapsed time in previous start-stop segments.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Tue Oct 27 06:30:40 2009 for OpenImageIO by  doxygen 1.6.1