| The Gaudi Framework v27r1

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

- File List
- File Members

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 }
167 inline ProcessTime& operator+=(const ProcessTime &rhs) {
168 i_kernel += rhs.i_kernel;
169 i_user += rhs.i_user;
170 i_elapsed += rhs.i_elapsed;
171 return *this;
172 }
173 private:
175 TimeValueType i_kernel, i_user, i_elapsed;
176 };
177
183 GAUDI_API ProcessTime getProcessTime(long pid = -1);
184
185 }
186
187 // implementation of the templated adjustTime
188 namespace System {
189 template <>
190 inline long long adjustTime<Year>(long long t) {
191 return (t==-1) ? t : t /= (1LL * 365 * 24 * 60 * 60 * 1000 * 1000 * 10);
192 }
193 template <>
194 inline long long adjustTime<Day>(long long t) {
195 return (t==-1) ? t : t /= (1LL * 24 * 60 * 60 * 1000 * 1000 * 10);
196 }
197 template <>
198 inline long long adjustTime<Hour>(long long t) {
199 return (t==-1) ? t : t /= (1LL * 60 * 60 * 1000 * 1000 * 10);
200 }
201 template <>
202 inline long long adjustTime<Min>(long long t) {
203 return (t==-1) ? t : t /= (60 * 1000 * 1000 * 10);
204 }
205 template <>
206 inline long long adjustTime<Sec>(long long t) {
207 return (t==-1) ? t : t /= (1000 * 1000 * 10);
208 }
209 template <>
210 inline long long adjustTime<milliSec>(long long t) {
211 return (t==-1) ? t : t /= (1000 * 10);
212 }
213 template <>
214 inline long long adjustTime<microSec>(long long t) {
215 return (t==-1) ? t : t /= (10LL);
216 }
217 template <>
218 inline long long adjustTime<nanoSec>(long long t) {
219 return (t==-1) ? t : t *= 100LL;
220 }
221 template <>
222 inline long long adjustTime<Month>(long long t) {
223 return (t==-1) ? t : t /= (1LL * 30 * 24 * 60 * 60 * 1000 * 1000 * 10);
224 }
225 template <>
226 inline long long adjustTime<Native>(long long t) {
227 return t;
228 }
229 }
230
231 #endif // GAUDIKERNEL_TIMING_H
System::userTime
GAUDI_API longlong userTime(TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
CPU user mode time of process in milliseconds.
Definition: Timing.cpp:158
Kernel.h
System::ProcessTime::ProcessTime
ProcessTime(TimeValueType k, TimeValueType u, TimeValueType e)
Constructor.
Definition: Timing.h:141
System::systemStart
GAUDI_API longlong systemStart(TimeType typ=Sec)
Maximum processing time left for this process.
Definition: Timing.cpp:97
System::ProcessTime::kernelTime
TimeValueType kernelTime() const
Retrieve the kernel time in the requested unit.
Definition: Timing.h:146
System::Min
Definition: Timing.h:51
System
Note: OS specific details for environment resolution.
Definition: Debugger.h:19
System::Times
Definition: SystemBase.h:20
System::ProcessTime::userTime
TimeValueType userTime() const
Retrieve the user time in the requested unit.
Definition: Timing.h:150
System::ProcessTime::operator-
ProcessTime operator-(const ProcessTime &rhs) const
Return the delta between two ProcessTime objects.
Definition: Timing.h:161
System::cpuTime
GAUDI_API longlong cpuTime(TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
Consumed CPU time of process in milliseconds.
Definition: Timing.cpp:168
System::adjustTime< Native >
long long adjustTime< Native >(long long t)
Definition: Timing.h:226
System::Hour
Definition: Timing.h:51
System::ProcessTime::ProcessTime
ProcessTime()
Constructor.
Definition: Timing.h:138
System::adjustTime< Month >
long long adjustTime< Month >(long long t)
Definition: Timing.h:222
System::ellapsedTime
GAUDI_API longlong ellapsedTime(TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
Elapsed time since start of process in milliseconds.
Definition: Timing.cpp:139
System::milliSec
Definition: Timing.h:51
System::upTime
GAUDI_API longlong upTime(TimeType typ=Hour)
Maximum processing time left for this process.
Definition: Timing.cpp:108
System::ProcessTime::i_kernel
TimeValueType i_kernel
Internal storage.
Definition: Timing.h:175
System::Sec
Definition: Timing.h:51
System::adjustTime< nanoSec >
long long adjustTime< nanoSec >(long long t)
Definition: Timing.h:218
System::tickCount
GAUDI_API longlong tickCount()
Retrieve the number of ticks since system startup.
Definition: Timing.cpp:65
System::microSec
Definition: Timing.h:51
System::adjustTime< Day >
long long adjustTime< Day >(long long t)
Definition: Timing.h:194
__longlong
Definition: Kernel.h:56
System::creationTime
GAUDI_API longlong creationTime(TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
Process Creation time.
Definition: Timing.cpp:114
System::TimeType
TimeType
Time type for conversion.
Definition: Timing.h:51
System::remainingTime
GAUDI_API longlong remainingTime(TimeType typ=milliSec, InfoType fetch=Quota, long pid=-1)
Maximum processing time left for this process.
Definition: Timing.cpp:124
System::Native
Definition: Timing.h:51
System::Quota
Definition: SystemBase.h:24
System::ProcessTime::i_user
TimeValueType i_user
Definition: Timing.h:175
System::kernelTime
GAUDI_API longlong kernelTime(TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
CPU kernel mode time of process in milliseconds.
Definition: Timing.cpp:148
System::adjustTime< milliSec >
long long adjustTime< milliSec >(long long t)
Definition: Timing.h:210
System::adjustTime< Year >
long long adjustTime< Year >(long long t)
Definition: Timing.h:190
System::ProcessTime
Simple class to hold the time information of a process.
Definition: Timing.h:133
System::adjustTime< microSec >
long long adjustTime< microSec >(long long t)
Definition: Timing.h:214
System::adjustTime< Min >
long long adjustTime< Min >(long long t)
Definition: Timing.h:202
System::Month
Definition: Timing.h:51
System::ProcessTime::TimeValueType
long long TimeValueType
Definition: Timing.h:135
System::ProcessTime::i_elapsed
TimeValueType i_elapsed
Definition: Timing.h:175
System::nanoSec
Definition: Timing.h:51
System::adjustTime
GAUDI_API longlong adjustTime(TimeType typ, longlong timevalue)
Convert time from OS native time to requested representation (Experts only)
Definition: Timing.cpp:37
System::ProcessTime::elapsedTime
TimeValueType elapsedTime() const
Retrieve the elapsed time in the requested unit.
Definition: Timing.h:154
System::getProcessTime
GAUDI_API ProcessTime getProcessTime(long pid=-1)
Retrieve the process time data for a process.
Definition: Timing.cpp:178
System::adjustTime< Hour >
long long adjustTime< Hour >(long long t)
Definition: Timing.h:198
System::ProcessTime::cpuTime
TimeValueType cpuTime() const
Retrieve the CPU (user+kernel) time in the requested unit.
Definition: Timing.h:158
System::ProcessTime::operator+=
ProcessTime & operator+=(const ProcessTime &rhs)
Add the timings to the current objects.
Definition: Timing.h:167
System::Year
Definition: Timing.h:51
System::adjustTime< Sec >
long long adjustTime< Sec >(long long t)
Definition: Timing.h:206
SystemBase.h
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
System::InfoType
InfoType
Enumeration for fetching information.
Definition: SystemBase.h:18
System::Day
Definition: Timing.h:51
System::currentTime
GAUDI_API longlong currentTime(TimeType typ=milliSec)
Retrieve absolute system time.
Definition: Timing.cpp:79