diff options
Diffstat (limited to 'SpMV/support/timer.h')
-rw-r--r-- | SpMV/support/timer.h | 27 |
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 + |