GLib Reference Manual
<<< Previous Page | Home | Up | Next Page >>>

# Timers

## Name

Timers -- functions to time operations.

## Synopsis

    #include <glib.h>

    struct      GTimer;
    GTimer*     g_timer_new                     (void);
    void        g_timer_start                   (GTimer *timer);
    void        g_timer_stop                    (GTimer *timer);
    gdouble     g_timer_elapsed                 (GTimer *timer,
                                                 gulong *microseconds);
    void        g_timer_reset                   (GTimer *timer);
    void        g_timer_destroy                 (GTimer *timer);

## Description

Timers can be used to time operations, in a similar way to a stopwatch. Call g_timer_new() to create the timer, g_timer_start() to start it, g_timer_elapsed() to determine the time which has elapsed since the timer was started, and g_timer_stop() to stop the timer.

## Details

### struct GTimer

    struct GTimer;

An opaque data structure which holds the timer information.

### g_timer_new ()

    GTimer*     g_timer_new                     (void);

Creates a new timer.

Returns : | the new timer.

### g_timer_start ()

    void        g_timer_start                   (GTimer *timer);

Starts the timer.

`timer` : | the timer.

### g_timer_stop ()

    void        g_timer_stop                    (GTimer *timer);

Stops the timer.

`timer` : | the timer.

### g_timer_elapsed ()

    gdouble     g_timer_elapsed                 (GTimer *timer,
                                                 gulong *microseconds);

`timer` : | the timer.
`microseconds` : | if non-NULL, this will be set to the microseconds component of the elapsed time (it does not include the number of seconds elapsed).
Returns : | the elapsed time in seconds, as a double.

### g_timer_reset ()

    void        g_timer_reset                   (GTimer *timer);

Resets the elapsed time to 0, leaving the timer running.

`timer` : | the timer.

### g_timer_destroy ()

    void        g_timer_destroy                 (GTimer *timer);

Destroys the timer, freeing the memory allocated for it.

`timer` : | the timer.

<<< Previous Page | Home | Up | Next Page >>>
Automatic String Completion | Windows Compatability Functions