| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Timing.h
Go to the documentation of this file.
1 //====================================================================
2 // Timing.h
3 //--------------------------------------------------------------------
4 //
5 // Package : Gaudi/System (The LHCb System service)
6 //
7 // Description: Definition of Systems internals
8 //
9 // Author : M.Frank
10 // Created : 13/1/99
11 //====================================================================
12 #ifndef GAUDIKERNEL_TIMING_H
13 #define GAUDIKERNEL_TIMING_H
14
15 // Framework include files
16 #include "GaudiKernel/Kernel.h"
17 #include "GaudiKernel/SystemBase.h"
18
49 namespace System {
51 enum TimeType { Year, Month, Day, Hour, Min, Sec, milliSec, microSec, nanoSec, Native };
52
54 GAUDI_API longlong adjustTime(TimeType typ, longlong timevalue);
55
57 template <TimeType T>
58 inline long long adjustTime(long long timevalue);
59
65 GAUDI_API longlong ellapsedTime(TimeType typ = milliSec, InfoType fetch = Times, long pid = -1);
73 GAUDI_API longlong kernelTime(TimeType typ = milliSec, InfoType fetch = Times, long pid = -1);
81 GAUDI_API longlong userTime(TimeType typ = milliSec, InfoType fetch = Times, long pid = -1);
89 GAUDI_API longlong cpuTime(TimeType typ = milliSec, InfoType fetch = Times, long pid = -1);
97 GAUDI_API longlong remainingTime(TimeType typ = milliSec, InfoType fetch = Quota, long pid = -1);
105 GAUDI_API longlong creationTime(TimeType typ = milliSec, InfoType fetch = Times, long pid = -1);
110 GAUDI_API longlong systemStart(TimeType typ = Sec);
115 GAUDI_API longlong upTime(TimeType typ = Hour);
120 GAUDI_API longlong currentTime(TimeType typ = milliSec);
124 GAUDI_API longlong tickCount();
125
133 class ProcessTime {
134 public:
135 typedef long long TimeValueType;
136
138 ProcessTime(): i_kernel(0), i_user(0), i_elapsed(0) {}
139
141 ProcessTime(TimeValueType k, TimeValueType u, TimeValueType e):
142 i_kernel(k), i_user(u), i_elapsed(e) {}
143
145 template <TimeType T>
146 inline TimeValueType kernelTime() const { return adjustTime<T>(i_kernel); }
147
149 template <TimeType T>
150 inline TimeValueType userTime() const { return adjustTime<T>(i_user); }
151
153 template <TimeType T>
154 inline TimeValueType elapsedTime() const { return adjustTime<T>(i_elapsed); }
155
157 template <TimeType T>
158 inline TimeValueType cpuTime() const { return adjustTime<T>(i_user + i_kernel); }
159
161 inline ProcessTime operator-(const ProcessTime &rhs) const {
162 return ProcessTime(i_kernel - rhs.i_kernel,
163 i_user - rhs.i_user,
164 i_elapsed - rhs.i_elapsed);
165 }
166 private:
168 TimeValueType i_kernel, i_user, i_elapsed;
169 };
170
176 GAUDI_API ProcessTime getProcessTime(long pid = -1);
177
178 }
179
180 // implementation of the templated adjustTime
181 namespace System {
182 template <>
183 inline long long adjustTime<Year>(long long t) {
184 return (t==-1) ? t : t /= (1LL * 365 * 24 * 60 * 60 * 1000 * 1000 * 10);
185 }
186 template <>
187 inline long long adjustTime<Day>(long long t) {
188 return (t==-1) ? t : t /= (1LL * 24 * 60 * 60 * 1000 * 1000 * 10);
189 }
190 template <>
191 inline long long adjustTime<Hour>(long long t) {
192 return (t==-1) ? t : t /= (1LL * 60 * 60 * 1000 * 1000 * 10);
193 }
194 template <>
195 inline long long adjustTime<Min>(long long t) {
196 return (t==-1) ? t : t /= (60 * 1000 * 1000 * 10);
197 }
198 template <>
199 inline long long adjustTime<Sec>(long long t) {
200 return (t==-1) ? t : t /= (1000 * 1000 * 10);
201 }
202 template <>
203 inline long long adjustTime<milliSec>(long long t) {
204 return (t==-1) ? t : t /= (1000 * 10);
205 }
206 template <>
207 inline long long adjustTime<microSec>(long long t) {
208 return (t==-1) ? t : t /= (10LL);
209 }
210 template <>
211 inline long long adjustTime<nanoSec>(long long t) {
212 return (t==-1) ? t : t *= 100LL;
213 }
214 template <>
215 inline long long adjustTime<Month>(long long t) {
216 return (t==-1) ? t : t /= (1LL * 30 * 24 * 60 * 60 * 1000 * 1000 * 10);
217 }
218 template <>
219 inline long long adjustTime<Native>(long long t) {
220 return t;
221 }
222 }
223
224 #endif // GAUDIKERNEL_TIMING_H