summaryrefslogtreecommitdiff
path: root/BFS/support/timer.h
diff options
context:
space:
mode:
Diffstat (limited to 'BFS/support/timer.h')
-rw-r--r--BFS/support/timer.h27
1 files changed, 17 insertions, 10 deletions
diff --git a/BFS/support/timer.h b/BFS/support/timer.h
index f8cd5fc..23116e3 100644
--- a/BFS/support/timer.h
+++ b/BFS/support/timer.h
@@ -6,22 +6,29 @@
#include <sys/time.h>
typedef struct Timer {
- struct timeval startTime;
- struct timeval endTime;
+ struct timeval startTime[4];
+ struct timeval stopTime[4];
+ double time[4];
} Timer;
-static void startTimer(Timer* timer) {
- gettimeofday(&(timer->startTime), NULL);
+static void startTimer(Timer *timer, int i, int rep) {
+ if(rep == 0) {
+ timer->time[i] = 0.0;
+ }
+ gettimeofday(&timer->startTime[i], NULL);
}
-static void stopTimer(Timer* timer) {
- gettimeofday(&(timer->endTime), NULL);
+static void stopTimer(Timer *timer, int i) {
+ gettimeofday(&timer->stopTime[i], NULL);
+ timer->time[i] += (timer->stopTime[i].tv_sec - timer->startTime[i].tv_sec) * 1000000.0 +
+ (timer->stopTime[i].tv_usec - timer->startTime[i].tv_usec);
}
-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));
+static void printAll(Timer *timer, int maxt) {
+ for (int i = 0; i <= maxt; i++) {
+ printf(" timer%d_us=%f", i, timer->time[i]);
+ }
+ printf("\n");
}
#endif
-