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 ARMv7 architecture. Default return 0.
22 extern "C" inline PentiumTimeType rdtscPentium() {
23  return 0;
24 }
25 #elif defined(__aarch64__)
26 #warning PentiumTimeType rdtscPentium() is not yet implemented for ARMv8 (AArch64) architecture. Default return 0.
27 extern "C" inline PentiumTimeType rdtscPentium() {
28  return 0;
29 }
30 #else
31 #error PentiumTimeType rdtscPentium() is not implemented for your CPU architecture.
32 #endif
33 
34 
35 
36 struct PentiumTime {
37 
38  struct OneTick {
39  OneTick();
40  ~OneTick();
41 
42  double one;
43  };
44 
45  static double oneTick() {
46  static const OneTick local;
47  return local.one;
48  };
49 
53 
54  inline static TimeType time() { return rdtscPentium();}
55  inline static TimeType time(int) { return rdtscPentium();}
56 
57 };
58 
59 
64 
65 
66 template<>
67 inline
68 GenTimer<PentiumTime>::GenTimer() : elapsed(0), running_(0), pid(0) {}
69 
70 #endif // UTILITIES_TIMING_PENTIUMTIMER_H
GenTimer()
constructor
Definition: GenTimer.h:87
static double oneTick()
Definition: PentiumTimer.h:45
static TimeType time(int)
Definition: PentiumTimer.h:55
static TimeType time()
Definition: PentiumTimer.h:54
PentiumTimeType TimeType
Definition: PentiumTimer.h:52
PentiumTimeIntervalType IntervalType
Definition: PentiumTimer.h:51
unsigned long long int PentiumTimeType
Definition: PentiumTimer.h:10
long long int PentiumTimeIntervalType
Definition: PentiumTimer.h:11
GenTimer< PentiumTime > PentiumTimer
Definition: PentiumTimer.h:63
GenTimeInterval< PentiumTime > TimeInterval
Definition: PentiumTimer.h:48
tuple pid
Definition: sysUtil.py:22
Definition: DDAxes.h:10