FastWallTimer.h

00001 # ifndef Conjecture_CpuTimer_h
00002 # define Conjecture_CpuTimer_h Conjecture_CpuTimer_h
00003 
00004 // Insert SVN header substitution variable here
00005 // Class Champion: Unassigned
00006 
00007 # include "Root.h"  // parent
00008 
00009 namespace Conjecture {
00010 
00011 #ifdef HAVE_RDTSC
00012 
00023     class FastWallTimer {
00024       public:
00025     // Types
00026 
00027         // Constructors/Destructors
00028         FastWallTimer();
00029 
00030         // Accessors
00031         inline const bool running() const { return this->_running; }
00032 
00033         inline const uint64_t cycles() const {
00034             if (this->_running)
00035                 return 0;
00036             else
00037                 return this->_end - this_start;
00038         }
00039 
00044         inline void start() {
00045             this->_running = true;
00046             this->_start = rdtsc();
00047         }
00048 
00053         inline void stop() {
00054             this->_start = rdtsc();
00055             this->_running = false;
00056         }
00057 
00058     private:
00059         inline uint64_t int rdtsc( void ) {
00060             uint64_t x;
00061             __asm__ volatile (".byte 0x0f, 0x31":"=A" (x));
00062             return x;
00063         }
00064 
00065         // State
00066         bool            _running;
00067         uint64_t        _start;
00068         uint64_t        _end;
00069     };
00070 #endif
00071 
00072 } // namespace
00073 
00074 #endif // Conjecture_CpuTimer_h

Generated on Thu Jun 15 19:56:09 2006 for Conjecture by  doxygen 1.4.6