]>
Commit | Line | Data |
---|---|---|
4d0891dd | 1 | #ifndef ALIL3_Stopwatch |
2 | #define ALIL3_Stopwatch | |
3 | ||
4 | #ifndef no_root | |
5 | #include <TStopwatch.h> | |
6 | typedef TStopwatch AliL3Stopwatch; | |
7 | ||
8 | #else | |
9 | #include <sys/types.h> | |
10 | #include <sys/times.h> | |
11 | #include <unistd.h> | |
12 | #include "AliL3RootTypes.h" | |
13 | ||
14 | class AliL3Stopwatch | |
15 | { | |
16 | private: | |
17 | static clock_t gTicks; | |
18 | enum EState { kUndefined, kStopped, kRunning }; | |
19 | ||
20 | Double_t fStartRealTime; //wall clock start time | |
21 | Double_t fStopRealTime; //wall clock stop time | |
22 | Double_t fStartCpuTime; //cpu start time | |
23 | Double_t fStopCpuTime; //cpu stop time | |
24 | Double_t fTotalCpuTime; //total cpu time | |
25 | Double_t fTotalRealTime; //total real time | |
26 | EState fState; //stopwatch state | |
27 | Int_t fCounter; //number of times the stopwatch was started | |
28 | ||
29 | public: | |
30 | ||
31 | AliL3Stopwatch(); | |
32 | ~AliL3Stopwatch(); | |
33 | void Start(Bool_t reset = kTRUE); | |
34 | void Stop(); | |
35 | void Continue(); | |
36 | Int_t Counter() const { return fCounter; } | |
37 | Double_t RealTime(); | |
38 | void Reset() { ResetCpuTime(); ResetRealTime(); } | |
39 | void ResetCpuTime (Double_t time = 0) { Stop(); fTotalCpuTime = time; } | |
40 | void ResetRealTime(Double_t time = 0) { Stop(); fTotalRealTime = time; } | |
41 | Double_t CpuTime(); | |
42 | void Print(Char_t *opt="") const; | |
43 | static Double_t GetRealTime(); | |
44 | static Double_t GetCPUTime(); | |
45 | ||
46 | ClassDef(TStopwatch,1) //A stopwatch which times real and cpu time | |
47 | }; | |
48 | ||
49 | #endif | |
50 | ||
51 | #endif |