1 #ifndef PHOOL_PHTIMER_H
2 #define PHOOL_PHTIMER_H
18 #define rdtsc(low, high) \
19 __asm__ __volatile__("rdtsc" \
20 : "=a"(low), "=d"(high))
71 void print(std::ostream& os = std::cout)
const
75 os <<
"time (ms): " << elapse << std::endl;
90 os <<
_name <<
": timer never started.\n";
134 void test(
double time, std::ostream& os = std::cout)
136 std::ostringstream
tmp;
137 tmp <<
"Test for " <<
_name <<
" - " << time <<
"ms";
138 PRINT(os, tmp.str());
140 usleep((
unsigned int) (time * 1000));
145 static void PRINT(std::ostream& os = std::cout,
const std::string&
message =
"");
159 catch (std::exception&
e)
161 std::cerr << e.what() << std::endl;
167 operator double()
const
186 void set_cpu_freq(
const std::string &cpuinfopath =
"/proc/cpuinfo");