Stopwatch timers for measuring elapsed time. More...
Go to the source code of this file.
Functions | |
struct stopwatch * | stopwatch_new () |
Create a new stopwatch. | |
void | stopwatch_delete (struct stopwatch *t) |
Delete a stopwatch. | |
void | stopwatch_reset (struct stopwatch *t) |
Reset a stopwatch. | |
void | stopwatch_start (struct stopwatch *t) |
Start a stopwatch. | |
void | stopwatch_stop (struct stopwatch *t) |
Stop a stopwatch. | |
double | stopwatch_elapsed (struct stopwatch *t) |
Get the elapsed time of a stopwatch. |
Stopwatch timers for measuring elapsed time.
Typical usage:
struct stopwatch *t = stopwatch_new(); stopwatch_reset(t); stopwatch_start(t); do_stuff(); stopwatch_stop(t); do_other_stuff(); stopwatch_start(t); do_stuff(); stopwatch_stop(t); double s = stopwatch_elapsed(t); stopwatch_delete(t);
Then s
contains the elapsed time in seconds for both do_stuff()
occasions, not including the time taken for do_other_stuff()
.
On POSIX, uses clock_gettime()
. On Windows, uses QueryPerformanceCounter()
.
Definition in file stopwatch.h.
void stopwatch_delete | ( | struct stopwatch * | t | ) |
Delete a stopwatch.
t | The stopwatch. |
Definition at line 135 of file stopwatch.c.
Referenced by poll_delete(), and render_end().
double stopwatch_elapsed | ( | struct stopwatch * | t | ) |
Get the elapsed time of a stopwatch.
t | The stopwatch. |
Definition at line 145 of file stopwatch.c.
References stopwatch::elapsed, stopwatch_start(), and stopwatch_stop().
Referenced by main(), poll_ui(), render_calculate(), and render_display().
|
read |
Create a new stopwatch.
Definition at line 32 of file stopwatch.c.
Referenced by main(), poll_new(), and render_begin().
void stopwatch_reset | ( | struct stopwatch * | t | ) |
Reset a stopwatch.
t | The stopwatch. |
Definition at line 139 of file stopwatch.c.
References stopwatch::elapsed, stopwatch_start(), and stopwatch_stop().
Referenced by main(), poll_set_timeout(), poll_ui(), and render_calculate().
void stopwatch_start | ( | struct stopwatch * | t | ) |
Start a stopwatch.
t | The stopwatch. |
Definition at line 36 of file stopwatch.c.
References stopwatch::start.
Referenced by poll_new(), stopwatch_elapsed(), and stopwatch_reset().
void stopwatch_stop | ( | struct stopwatch * | t | ) |
Stop a stopwatch.
t | The stopwatch. |
Definition at line 40 of file stopwatch.c.
References stopwatch::elapsed, stopwatch::start, stopwatch::stop, and time_difference().
Referenced by stopwatch_elapsed(), and stopwatch_reset().