summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2013-07-04 16:58:14 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2013-07-04 16:58:14 +0200
commit8c04f3936822c13acdb6711ccd3159395a96ee0b (patch)
tree571f9e0b19a1034df0aa92517a623f3c8a870b00
parentb9ce6027dde8b3c6fd002d38e3cee07e7711d73c (diff)
downloadlibufodecode-8c04f3936822c13acdb6711ccd3159395a96ee0b.tar.gz
libufodecode-8c04f3936822c13acdb6711ccd3159395a96ee0b.tar.bz2
libufodecode-8c04f3936822c13acdb6711ccd3159395a96ee0b.tar.xz
libufodecode-8c04f3936822c13acdb6711ccd3159395a96ee0b.zip
Make Timer private and calculate elapsed seconds
-rw-r--r--test/ipedec.c6
-rw-r--r--test/timer.c12
-rw-r--r--test/timer.h15
3 files changed, 21 insertions, 12 deletions
diff --git a/test/ipedec.c b/test/ipedec.c
index 52aebb0..f171cc8 100644
--- a/test/ipedec.c
+++ b/test/ipedec.c
@@ -21,6 +21,7 @@ typedef struct {
int convert_bayer;
} Options;
+
static int
read_raw_file(const char *filename, char **buffer, size_t *length)
{
@@ -103,7 +104,6 @@ print_meta_data (UfoDecoderMeta *meta)
printf("\n");
}
-
static int
process_file(const char *filename, Options *opts)
{
@@ -217,8 +217,8 @@ process_file(const char *filename, Options *opts)
fclose(fp);
if (opts->verbose) {
- mtime = timer->seconds * 1000.0 + timer->useconds / 1000.0;
- printf("Decoded %i frames in %.5fms\n", n_frames, mtime);
+ printf("Decoded %i frames in %.5fms\n", n_frames,
+ timer_get_seconds (timer) * 1000.0);
}
if (opts->convert_bayer)
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;
+}
diff --git a/test/timer.h b/test/timer.h
index 272f69d..3367367 100644
--- a/test/timer.h
+++ b/test/timer.h
@@ -3,15 +3,12 @@
#include <sys/time.h>
-typedef struct {
- struct timeval start;
- long seconds;
- long useconds;
-} Timer;
+typedef struct _Timer Timer;
-Timer * timer_new (void);
-void timer_destroy (Timer *t);
-void timer_start (Timer *t);
-void timer_stop (Timer *t);
+Timer * timer_new (void);
+void timer_destroy (Timer *t);
+void timer_start (Timer *t);
+void timer_stop (Timer *t);
+double timer_get_seconds (Timer *t);
#endif