summaryrefslogtreecommitdiff
path: root/src/c/jerasure/include/timing.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/c/jerasure/include/timing.h')
-rw-r--r--src/c/jerasure/include/timing.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/c/jerasure/include/timing.h b/src/c/jerasure/include/timing.h
new file mode 100644
index 0000000..b489d0d
--- /dev/null
+++ b/src/c/jerasure/include/timing.h
@@ -0,0 +1,43 @@
+// Timing measurement utilities.
+
+#ifndef JERASURE_INCLUDED__TIMING_H
+#define JERASURE_INCLUDED__TIMING_H
+
+// Define USE_CLOCK to use clock(). Otherwise use gettimeofday().
+#define USE_CLOCK
+
+#ifdef USE_CLOCK
+#include <time.h>
+#else
+#include <sys/time.h>
+#endif
+
+struct timing {
+#ifdef USE_CLOCK
+ clock_t clock;
+#else
+ struct timeval tv;
+#endif
+};
+
+// Get the current time as a double in seconds.
+double
+timing_now(
+ void);
+
+// Set *t to the current time.
+void
+timing_set(
+ struct timing * t);
+
+// Get *t as a double in seconds.
+double
+timing_get(
+ struct timing * t);
+
+// Return *t2 - *t1 as a double in seconds.
+double
+timing_delta(
+ struct timing * t1,
+ struct timing * t2);
+#endif