CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/Utilities/Timing/interface/PentiumTimer.h

Go to the documentation of this file.
00001 #ifndef UTILITIES_TIMING_PENTIUMTIMER_H
00002 #define UTILITIES_TIMING_PENTIUMTIMER_H
00003 //
00004 //
00005 //   V 0.0 
00006 //
00007 
00008 #include "Utilities/Timing/interface/GenTimer.h"
00009 
00010 typedef unsigned long long int PentiumTimeType;
00011 typedef long long int PentiumTimeIntervalType;
00012 
00013 extern "C" inline PentiumTimeType rdtscPentium() {
00014   PentiumTimeType x;
00015   // Works only for x86 machines in protected mode.
00016   __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
00017   return x;
00018 }
00019 
00020 
00021 
00022 struct PentiumTime {
00023 
00024   struct OneTick {
00025     OneTick();
00026     ~OneTick();
00027     
00028     double one;
00029   };
00030   
00031   static double oneTick() {
00032     static OneTick local;
00033     return local.one;
00034   };
00035 
00036   typedef GenTimeInterval<PentiumTime> TimeInterval;
00037   typedef PentiumTimeIntervalType IntervalType;
00038   typedef PentiumTimeType TimeType;
00039 
00040   inline static TimeType time() { return rdtscPentium();}
00041   inline static TimeType time(int) { return rdtscPentium();}
00042 
00043 };
00044 
00045 
00049 typedef GenTimer<PentiumTime> PentiumTimer; 
00050 
00051 
00052 template<>
00053 inline 
00054 GenTimer<PentiumTime>::GenTimer() : elapsed(0),  running_(0), pid(0) {}
00055 
00056 #endif // UTILITIES_TIMING_PENTIUMTIMER_H