summaryrefslogtreecommitdiff
path: root/SpMV/support/timer.h
diff options
context:
space:
mode:
authorJuan Gomez Luna <juan.gomez@safari.ethz.ch>2021-06-16 19:46:05 +0200
committerJuan Gomez Luna <juan.gomez@safari.ethz.ch>2021-06-16 19:46:05 +0200
commit3de4b495fb176eba9a0eb517a4ce05903cb67acb (patch)
treefc6776a94549d2d4039898f183dbbeb2ce013ba9 /SpMV/support/timer.h
parentef5c3688c486b80a56d3c1cded25f2b2387f2668 (diff)
PrIM -- first commit
Diffstat (limited to 'SpMV/support/timer.h')
-rw-r--r--SpMV/support/timer.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/SpMV/support/timer.h b/SpMV/support/timer.h
new file mode 100644
index 0000000..f8cd5fc
--- /dev/null
+++ b/SpMV/support/timer.h
@@ -0,0 +1,27 @@
+
+#ifndef _TIMER_H_
+#define _TIMER_H_
+
+#include <stdio.h>
+#include <sys/time.h>
+
+typedef struct Timer {
+ struct timeval startTime;
+ struct timeval endTime;
+} Timer;
+
+static void startTimer(Timer* timer) {
+ gettimeofday(&(timer->startTime), NULL);
+}
+
+static void stopTimer(Timer* timer) {
+ gettimeofday(&(timer->endTime), NULL);
+}
+
+static float getElapsedTime(Timer timer) {
+ return ((float) ((timer.endTime.tv_sec - timer.startTime.tv_sec)
+ + (timer.endTime.tv_usec - timer.startTime.tv_usec)/1.0e6));
+}
+
+#endif
+