summaryrefslogtreecommitdiff
path: root/SpMV/include/timer.h
diff options
context:
space:
mode:
authorBirte Kristina Friesel <birte.friesel@uos.de>2025-05-23 16:28:17 +0200
committerBirte Kristina Friesel <birte.friesel@uos.de>2025-05-23 16:28:35 +0200
commitfa6c70a44fc56cc50370e57c460dd61e8f127b51 (patch)
tree91269761966dccea80a2931542db5a3648f66e18 /SpMV/include/timer.h
parent2e3a43c12df8115fc859248adb14b87e08becb77 (diff)
SpMV: Add AspectC++ support
Diffstat (limited to 'SpMV/include/timer.h')
-rw-r--r--SpMV/include/timer.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/SpMV/include/timer.h b/SpMV/include/timer.h
new file mode 100644
index 0000000..cb513cb
--- /dev/null
+++ b/SpMV/include/timer.h
@@ -0,0 +1,54 @@
+#pragma once
+
+#include <stdio.h>
+#include <sys/time.h>
+
+#if DFATOOL_TIMING
+
+#define dfatool_printf(fmt, ...) do { printf(fmt, __VA_ARGS__); } while (0)
+
+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 double getElapsedTime(Timer timer)
+{
+ return ((double)((timer.endTime.tv_sec - timer.startTime.tv_sec)
+ + (timer.endTime.tv_usec -
+ timer.startTime.tv_usec) / 1.0e6));
+}
+
+#else
+
+#define dfatool_printf(fmt, ...) do {} while (0)
+
+typedef int Timer;
+
+static void startTimer(Timer* timer)
+{
+ (void)timer;
+}
+
+static void stopTimer(Timer* timer)
+{
+ (void)timer;
+}
+
+static double getElapsedTime(Timer timer)
+{
+ (void)timer;
+ return 0.0;
+}
+
+#endif