FastWallTimer.h

00001 # ifndef CpuTimer_h
00002 # define CpuTimer_h CpuTimer_h
00003 
00004 // ####################################################################
00005 // # SomeName: An Extensible Optical Character Recognition Framework  #
00006 // #                                                                  #
00007 // # Copyright: Lesser GNU Public License (LGPL)                      #
00008 // #                                                                  #
00009 // # Overview:                                                        #
00010 // #  - SomeName is a collection of C++ classes, and an OCR engine    #
00011 // #  - SomeName is designed to allow customization at all levels     #
00012 // #    and to encourage individuals to contribute incremental        #
00013 // #    improvements in algorithms.                                   #
00014 // #  - Overall design discussions can be found in                    #
00015 // #      $SNROOT/docs/doxygen/html/index.html                        #
00016 // #  - SomeName is designed to interact with and build on other      #
00017 // #    open-source OCR programs.                                     #
00018 // ####################################################################
00019 
00020 # include "Root.h"  // parent
00021 
00022 namespace Conjecture {
00023 
00024 #ifdef HAVE_RDTSC
00025     // ##################################################################
00033     class FastWallTimer {
00034       public:
00035     // Types
00036 
00037         // Constructors/Destructors
00038         FastWallTimer();
00039 
00040         // **************
00041         // Accessors
00042         inline const bool running() const { return this->_running; }
00043 
00044         // **************
00045         // Input/Output
00046 
00047         // **************
00048         // Interface
00049 
00051         inline void start() {
00052             this->_start = rdtsc();
00053         }
00054 
00056         inline void stop() {
00057             this->_start = rdtsc();
00058         }
00059 
00060     private:
00061         inline uint64_t int rdtsc( void ) {
00062             uint64_t x;
00063             __asm__ volatile (".byte 0x0f, 0x31":"=A" (x));
00064             return x;
00065         }
00066 
00067         // **************
00068         // State
00069         bool            _running;
00070         uint64_t        _start;
00071         uint64_t        _end;
00072     };
00073 #endif
00074 
00075 } // namespace
00076 
00077 #endif

Generated on Wed Jun 14 15:08:02 2006 for Conjecture by  doxygen 1.4.6