16 #ifndef IMPALA_UTIL_STOPWATCH_H
17 #define IMPALA_UTIL_STOPWATCH_H
19 #include <boost/cstdint.hpp>
56 __asm__ __volatile__ (
57 "xorl %%eax,%%eax \n cpuid"
58 :::
"%rax",
"%rbx",
"%rcx",
"%rdx");
59 __asm__ __volatile__ (
"rdtsc" :
"=a" (lo),
"=d" (hi));
83 clock_gettime(CLOCK_MONOTONIC, &
start_);
99 clock_gettime(CLOCK_MONOTONIC, &
start_);
108 clock_gettime(CLOCK_MONOTONIC, &end);
109 return (end.tv_sec -
start_.tv_sec) * 1000L * 1000L * 1000L +
110 (end.tv_nsec -
start_.tv_nsec);
uint64_t ElapsedTime() const
Returns time in cpu ticks.
uint64_t Reset()
Restarts the timer. Returns the elapsed time until this point.
uint64_t ElapsedTime() const
Returns time in nanosecond.