summaryrefslogtreecommitdiffstats
path: root/test/timer.c
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2013-07-04 16:46:30 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2013-07-04 16:46:30 +0200
commitb9ce6027dde8b3c6fd002d38e3cee07e7711d73c (patch)
tree3adf5e718ffc28f300f2449f115f628162fe96f2 /test/timer.c
parent67d068f7c843e980141cbabad9560154024a1366 (diff)
downloadufodecode-b9ce6027dde8b3c6fd002d38e3cee07e7711d73c.tar.gz
ufodecode-b9ce6027dde8b3c6fd002d38e3cee07e7711d73c.tar.bz2
ufodecode-b9ce6027dde8b3c6fd002d38e3cee07e7711d73c.tar.xz
ufodecode-b9ce6027dde8b3c6fd002d38e3cee07e7711d73c.zip
Move timer functions into timer.{c,h}
Diffstat (limited to 'test/timer.c')
-rw-r--r--test/timer.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/timer.c b/test/timer.c
new file mode 100644
index 0000000..43aff84
--- /dev/null
+++ b/test/timer.c
@@ -0,0 +1,33 @@
+#include <stdlib.h>
+#include "timer.h"
+
+
+Timer *
+timer_new (void)
+{
+ Timer *t = (Timer *) malloc (sizeof (Timer));
+ t->seconds = t->useconds = 0L;
+ return t;
+}
+
+void
+timer_destroy (Timer *t)
+{
+ free (t);
+}
+
+void
+timer_start (Timer *t)
+{
+ gettimeofday(&t->start, NULL);
+}
+
+void
+timer_stop (Timer *t)
+{
+ struct timeval end;
+
+ gettimeofday(&end, NULL);
+ t->seconds += end.tv_sec - t->start.tv_sec;
+ t->useconds += end.tv_usec - t->start.tv_usec;
+}