11 #ifndef SRC_INCLUDE_SMASH_TSC_H_ 
   12 #define SRC_INCLUDE_SMASH_TSC_H_ 
   14 #ifndef USE_NANOBENCHMARKING_CODE 
   15 #error "Nanobenchmark code tried to be used without enabling it via CMake." 
   23 #pragma intrinsic(__rdtsc) 
   34 class TimeStampCounter {
 
   43   uint64_t cycles() 
const;
 
   59 inline void TimeStampCounter::start() {
 
   61   asm volatile(
"xor %%eax,%%eax\n\tcpuid\n\trdtsc" 
   62                : 
"=a"(m_start.b[0]), 
"=d"(m_start.b[1])::
"ebx", 
"ecx");
 
   63 #elif defined _MSC_VER 
   65   m_start.a = __rdtscp(&tmp);
 
   67   asm volatile(
"rdtscp" : 
"=a"(m_start.b[0]), 
"=d"(m_start.b[1])::
"ecx");
 
   71 inline void TimeStampCounter::stop() {
 
   73   asm volatile(
"xor %%eax,%%eax\n\tcpuid\n\trdtsc" 
   74                : 
"=a"(m_end.b[0]), 
"=d"(m_end.b[1])::
"ebx", 
"ecx");
 
   75 #elif defined _MSC_VER 
   77   m_end.a = __rdtscp(&tmp);
 
   79   asm volatile(
"rdtscp" : 
"=a"(m_end.b[0]), 
"=d"(m_end.b[1])::
"ecx");
 
   83 inline uint64_t TimeStampCounter::cycles()
 const { 
return m_end.a - m_start.a; }
 
   85 std::ostream &
operator<<(std::ostream &out, 
const TimeStampCounter &tsc);
 
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.