diff options
Diffstat (limited to 'test/timer.c')
-rw-r--r-- | test/timer.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/timer.c b/test/timer.c index 43aff84..987f18d 100644 --- a/test/timer.c +++ b/test/timer.c @@ -1,6 +1,12 @@ #include <stdlib.h> #include "timer.h" +struct _Timer { + struct timeval start; + long seconds; + long useconds; +}; + Timer * timer_new (void) @@ -31,3 +37,9 @@ timer_stop (Timer *t) t->seconds += end.tv_sec - t->start.tv_sec; t->useconds += end.tv_usec - t->start.tv_usec; } + +double +timer_get_seconds (Timer *t) +{ + return t->seconds + t->useconds / 1000.0 / 1000.0; +} |