]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/misc/AliHLTStopwatch.h
compilation warnings corrected
[u/mrichter/AliRoot.git] / HLT / misc / AliHLTStopwatch.h
1 // @(#) $Id$
2
3 #ifndef ALIL3_Stopwatch
4 #define ALIL3_Stopwatch
5
6 #ifndef no_root
7 #include <TStopwatch.h>
8 typedef TStopwatch AliHLTStopwatch; 
9
10 #else
11 #include <sys/types.h>
12 #include <sys/times.h>
13 #include <unistd.h>
14 #include "AliHLTRootTypes.h"
15
16 class AliHLTStopwatch
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   AliHLTStopwatch();
34   ~AliHLTStopwatch();
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 typedef AliHLTStopwatch AliL3Stopwatch; // for backward compatibility
54
55 #endif