summaryrefslogtreecommitdiff
path: root/Microbenchmarks/STREAM/support
diff options
context:
space:
mode:
Diffstat (limited to 'Microbenchmarks/STREAM/support')
-rw-r--r--Microbenchmarks/STREAM/support/timer.h24
1 files changed, 11 insertions, 13 deletions
diff --git a/Microbenchmarks/STREAM/support/timer.h b/Microbenchmarks/STREAM/support/timer.h
index b53d95f..901baac 100644
--- a/Microbenchmarks/STREAM/support/timer.h
+++ b/Microbenchmarks/STREAM/support/timer.h
@@ -33,27 +33,25 @@
*
*/
-#include <sys/time.h>
+#include <time.h>
-typedef struct Timer{
+typedef struct Timer {
- struct timeval startTime[7];
- struct timeval stopTime[7];
- double time[7];
+ struct timespec startTime[7];
+ struct timespec stopTime[7];
+ uint64_t nanoseconds[7];
-}Timer;
+} Timer;
void start(Timer *timer, int i, int rep) {
if(rep == 0) {
- timer->time[i] = 0.0;
+ timer->nanoseconds[i] = 0;
}
- gettimeofday(&timer->startTime[i], NULL);
+ clock_gettime(CLOCK_MONOTONIC, &timer->startTime[i]);
}
void stop(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);
+ clock_gettime(CLOCK_MONOTONIC, &timer->stopTime[i]);
+ timer->nanoseconds[i] += (timer->stopTime[i].tv_sec - timer->startTime[i].tv_sec) * 1000000000 +
+ (timer->stopTime[i].tv_nsec - timer->startTime[i].tv_nsec);
}
-
-void print(Timer *timer, int i, int REP) { printf("Time (ms): %f\t", timer->time[i] / (1000 * REP)); }