24 #ifndef GRAPHLAB_TIMER_HPP
25 #define GRAPHLAB_TIMER_HPP
83 inline void start() { gettimeofday(&start_time_, NULL); }
93 gettimeofday(¤t_time, NULL);
97 (double)(current_time.tv_sec - start_time_.tv_sec) +
98 ((double)(current_time.tv_usec - start_time_.tv_usec))/1.0E6;
116 gettimeofday(¤t_time, NULL);
118 (double)current_time.tv_sec + ((
double)current_time.tv_usec)/1.0E6;
128 gettimeofday(¤t_time, NULL);
130 (size_t)current_time.tv_sec * 1000000 + (
size_t)current_time.tv_usec;
153 static void sleep(
size_t sleeplen);
158 static void sleep_ms(
size_t sleeplen);
162 unsigned long long estimate_ticks_per_second();
164 #if defined(__i386__)
165 static inline unsigned long long rdtsc(
void)
167 unsigned long long int x;
168 __asm__
volatile (
".byte 0x0f, 0x31" :
"=A" (x));
171 #elif defined(__x86_64__)
172 static inline unsigned long long rdtsc(
void)
175 __asm__ __volatile__ (
"rdtsc" :
"=a"(lo),
"=d"(hi));
176 return ( (
unsigned long long)lo) | ( ((
unsigned long long)hi)<<32 );
179 static inline unsigned long long rdtsc(
void) {