From 8c04f3936822c13acdb6711ccd3159395a96ee0b Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Thu, 4 Jul 2013 16:58:14 +0200 Subject: Make Timer private and calculate elapsed seconds --- test/timer.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/timer.c') 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 #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; +} -- cgit v1.2.3