diff options
author | Birte Kristina Friesel <birte.friesel@uos.de> | 2025-05-23 16:28:17 +0200 |
---|---|---|
committer | Birte Kristina Friesel <birte.friesel@uos.de> | 2025-05-23 16:28:35 +0200 |
commit | fa6c70a44fc56cc50370e57c460dd61e8f127b51 (patch) | |
tree | 91269761966dccea80a2931542db5a3648f66e18 /SpMV/include/timer.h | |
parent | 2e3a43c12df8115fc859248adb14b87e08becb77 (diff) |
SpMV: Add AspectC++ support
Diffstat (limited to 'SpMV/include/timer.h')
-rw-r--r-- | SpMV/include/timer.h | 54 |
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 |