CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PentiumTimer.h
Go to the documentation of this file.
1 #ifndef UTILITIES_TIMING_PENTIUMTIMER_H
2 #define UTILITIES_TIMING_PENTIUMTIMER_H
3 //
4 //
5 // V 0.0
6 //
7 
9 
10 typedef unsigned long long int PentiumTimeType;
11 typedef long long int PentiumTimeIntervalType;
12 
13 #if defined(__x86_64__) || defined(__i386__)
14 extern "C" inline PentiumTimeType rdtscPentium() {
16  // Works only for x86 machines in protected mode.
17  __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
18  return x;
19 }
20 #elif defined(__arm__)
21 #warning PentiumTimeType rdtscPentium() is not yet implemented for ARM architecture. Default return 0.
22 extern "C" inline PentiumTimeType rdtscPentium() {
23  return 0;
24 }
25 #else
26 #error PentiumTimeType rdtscPentium() is not implemented for your CPU architecture.
27 #endif
28 
29 
30 
31 struct PentiumTime {
32 
33  struct OneTick {
34  OneTick();
35  ~OneTick();
36 
37  double one;
38  };
39 
40  static double oneTick() {
41  static OneTick local;
42  return local.one;
43  };
44 
48 
49  inline static TimeType time() { return rdtscPentium();}
50  inline static TimeType time(int) { return rdtscPentium();}
51 
52 };
53 
54 
59 
60 
61 template<>
62 inline
63 GenTimer<PentiumTime>::GenTimer() : elapsed(0), running_(0), pid(0) {}
64 
65 #endif // UTILITIES_TIMING_PENTIUMTIMER_H
GenTimer()
constructor
Definition: GenTimer.h:87
static double oneTick()
Definition: PentiumTimer.h:40
static TimeType time(int)
Definition: PentiumTimer.h:50
static TimeType time()
Definition: PentiumTimer.h:49
PentiumTimeType TimeType
Definition: PentiumTimer.h:47
PentiumTimeIntervalType IntervalType
Definition: PentiumTimer.h:46
unsigned long long int PentiumTimeType
Definition: PentiumTimer.h:10
long long int PentiumTimeIntervalType
Definition: PentiumTimer.h:11
GenTimer< PentiumTime > PentiumTimer
Definition: PentiumTimer.h:58
GenTimeInterval< PentiumTime > TimeInterval
Definition: PentiumTimer.h:43
tuple pid
Definition: sysUtil.py:22
Definition: DDAxes.h:10