BAM
Abstract Machine for Bottom-Up Evaluation with the Push Method
perf.h
Go to the documentation of this file.
1 // ============================================================================
2 // Project: Deductive Database
3 // Filename: perf.h
4 // Purpose: Performance measurement functions, especially timer.
5 // Last Change: 11.08.2017
6 // Language: C++
7 // EMail: brass@informatik.uni-halle.de
8 // WWW: http://www.informatik.uni-halle.de/~brass/
9 // Address: Feldschloesschen 15, D-06120 Halle (Saale), GERMANY
10 // Copyright: (c) 2010-2017 by Stefan Brass
11 // License: See file "LICENSE" for copying conditions.
12 // Note: There is no warranty at all - this code may contain bugs.
13 // ============================================================================
14 
15 
22 //=============================================================================
23 // Include File Frame:
24 //=============================================================================
25 
26 #ifndef PERF_INCLUDED
27 #define PERF_INCLUDED
28 
29 //=============================================================================
30 // Used Types and Macros:
31 //=============================================================================
32 
33 #ifndef VER_INCLUDED
34 #include "ver.h"
35 #endif
36 
37 #ifndef CHECK_INCLUDED
38 #include "check.h"
39 #endif
40 
41 
42 //=============================================================================
43 // Private Constants:
44 //=============================================================================
45 
46 //-----------------------------------------------------------------------------
47 // PERF_MAGIC: Magic number (identifies objects of this class).
48 //-----------------------------------------------------------------------------
49 
50 static const long PERF_MAGIC = 0x5045520AL; // 'PER\n'
51 
52 
53 //=============================================================================
54 // Class for Time Measurements:
55 //=============================================================================
56 
57 
69 class perf_c {
70  public:
71 
72 
73 //-----------------------------------------------------------------------------
74 // Constructor, Destructor:
75 //-----------------------------------------------------------------------------
76 
77  // Constructor:
78  perf_c();
79 
80  // Destructor:
81  ~perf_c();
82 
83 //-----------------------------------------------------------------------------
84 // (Object) Methods:
85 //-----------------------------------------------------------------------------
86 
87  //---------------------------------------------------------------------
88  // start:
89  //---------------------------------------------------------------------
90 
95  void start();
96 
97  //---------------------------------------------------------------------
98  // stop:
99  //---------------------------------------------------------------------
100 
105  void stop();
106 
107  //---------------------------------------------------------------------
108  // realtime_msec:
109  //---------------------------------------------------------------------
110 
115  long int realtime_msec();
116 
117  //---------------------------------------------------------------------
118  // cputime_msec:
119  //---------------------------------------------------------------------
120 
125  long int cputime_msec();
126 
127 
128 //-----------------------------------------------------------------------------
129 // Debugging Support:
130 //-----------------------------------------------------------------------------
131 
132 #if VER_DEBUG
133 
134  //---------------------------------------------------------------------
135  // check:
136  //---------------------------------------------------------------------
137 
138  public:
139 
144  str_t check() const;
145 
146  //---------------------------------------------------------------------
147  // Magic number (identifies objects of this class for debugging).
148  //---------------------------------------------------------------------
149 
150  private:
151  long Magic; // Must be "PERF_MAGIC".
152 #endif
153 
154 //-----------------------------------------------------------------------------
155 // Copy-constructor and assignment operator are not supported for this class:
156 //-----------------------------------------------------------------------------
157 
158  private:
159 
160  perf_c(const perf_c& perf); // Not implemented
161  perf_c& operator=(const perf_c& perf); // Not implemented
162 
163 //-----------------------------------------------------------------------------
164 // Private Object Members:
165 //-----------------------------------------------------------------------------
166 
167  private:
168 
169  // ID: Index in OS-dependent table of timer data (-1 if none free).
170  int ID;
171 
172 
173 //=============================================================================
174 // End of Class:
175 //=============================================================================
176 
177 };
178 
179 //-----------------------------------------------------------------------------
180 // Define pointer type:
181 //-----------------------------------------------------------------------------
182 
187 typedef perf_c *perf_t;
188 
189 //-----------------------------------------------------------------------------
190 // Define null pointer:
191 //-----------------------------------------------------------------------------
192 
197 #define PERF_NULL (static_cast<perf_t>(0))
198 
199 //=============================================================================
200 // End of Include File:
201 //=============================================================================
202 
203 #endif
204 
Runtime assertion check.
void start()
Definition: perf.cpp:148
perf_c * perf_t
Definition: perf.h:187
long int cputime_msec()
Definition: perf.cpp:270
Definition: perf.h:69
void stop()
Definition: perf.cpp:191
long int realtime_msec()
Definition: perf.cpp:231
const char * str_t
Definition: str.h:41
Some basic version settings.