Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::G::Timer Class Reference

A GTimer C++ wrapper interface. More...

`#include <inti/glib/timer.h>`

Inheritance diagram for Inti::G::Timer:

List of all members.

## Public Member Functions

Constructors

- Timer ()
    Constructs a new timer, and starts timing (that is, start() is implicitly called for you).
- virtual ~Timer ()
    Destructor.

Accessors

- GTimer * g_timer () const
    Get a pointer to the GTimer object.
- operator GTimer * () const
    Conversion operator; Safely converts a G::Timer object into a GTimer pointer.

Methods

- void start ()
    Marks a start time, so that future calls to elapsed() will report the time since start() was called.
- void stop ()
    Marks an end time, so calls to elapsed() will return the difference between this end time and the start time.
- void reset ()
    Reset an already started timer to zero.
- double elapsed (unsigned long *microseconds=0)
    Obtains the elapsed time.

## Detailed Description

A GTimer C++ wrapper interface.

Timer records a start time, and counts microseconds elapsed since that time. This is done somewhat differently on different platforms, and can be tricky to get exactly right, so Timer provides a portable and convenient interface.

There is not much you can do with a timer. You can construct it, start() it running, stop() it running, and reset() it to zero.

## Member Function Documentation

double Inti::G::Timer::elapsed | ( | unsigned long * | microseconds = 0 | ) |

Obtains the elapsed time.

Parameters:

  microseconds | The fractional part of seconds elapsed, in microseconds, or null.

Returns:
  The seconds elapsed as a floating point value, including any fractional part.

If a timer has been started but not stopped this method obtains the time since the timer was started. If timer has been stopped it obtains the elapsed time between the time it was started and the time it was stopped. The return value is the number of seconds elapsed, including any fractional part. If microseconds is non-null, it will be set to the microseconds fraction of the elapsed time. It does not contain the seconds. The microseconds out parameter is not very useful.

void Inti::G::Timer::reset | ( |  | ) |

| Reset an already started timer to zero. It's fine to call start() on an already-started timer to reset the start time, so reset() serves no real purpose, other than to make the intentions of your code a bit clearer.

void Inti::G::Timer::start | ( |  | ) |

| Marks a start time, so that future calls to elapsed() will report the time since start() was called. When you construct a new timer this method automatically marks the start time, so there is no need to call start() immediately after constructing the timer.

The documentation for this class was generated from the following file:

- timer.h

Main Page - Footer