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