Logo ROOT   6.08/07
Reference Guide
TStopwatch.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Fons Rademakers 11/10/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TStopwatch
13 #define ROOT_TStopwatch
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TStopwatch //
19 // //
20 // Stopwatch class. This class returns the real and cpu time between //
21 // the start and stop events. //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 
25 #ifndef ROOT_TObject
26 #include "TObject.h"
27 #endif
28 
29 
30 class TStopwatch : public TObject {
31 
32 private:
34 
35  Double_t fStartRealTime; //wall clock start time
36  Double_t fStopRealTime; //wall clock stop time
37  Double_t fStartCpuTime; //cpu start time
38  Double_t fStopCpuTime; //cpu stop time
39  Double_t fTotalCpuTime; //total cpu time
40  Double_t fTotalRealTime; //total real time
41  EState fState; //stopwatch state
42  Int_t fCounter; //number of times the stopwatch was started
43 
44  static Double_t GetRealTime();
45  static Double_t GetCPUTime();
46 
47 public:
48  TStopwatch();
49  void Start(Bool_t reset = kTRUE);
50  void Stop();
51  void Continue();
52  Int_t Counter() const { return fCounter; }
54  void Reset() { ResetCpuTime(); ResetRealTime(); }
55  void ResetCpuTime(Double_t time = 0) { Stop(); fTotalCpuTime = time; }
56  void ResetRealTime(Double_t time = 0) { Stop(); fTotalRealTime = time; }
57  Double_t CpuTime();
58  void Print(Option_t *option="") const;
59 
60  ClassDef(TStopwatch,1) //A stopwatch which times real and cpu time
61 };
62 
63 #endif
EState fState
Definition: TStopwatch.h:41
Double_t fTotalRealTime
Definition: TStopwatch.h:40
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
Definition: TStopwatch.cxx:110
void Print(Option_t *option="") const
Print the real and cpu time passed between the start and stop events.
Definition: TStopwatch.cxx:219
const char Option_t
Definition: RtypesCore.h:62
void ResetRealTime(Double_t time=0)
Definition: TStopwatch.h:56
Double_t fStartCpuTime
Definition: TStopwatch.h:37
TStopwatch()
Create a stopwatch and start it.
Definition: TStopwatch.cxx:39
void ResetCpuTime(Double_t time=0)
Definition: TStopwatch.h:55
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
Definition: TStopwatch.cxx:125
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void Stop()
Stop the stopwatch.
Definition: TStopwatch.cxx:77
#define ClassDef(name, id)
Definition: Rtypes.h:254
void Continue()
Resume a stopped stopwatch.
Definition: TStopwatch.cxx:93
static Double_t GetCPUTime()
Private static method returning system CPU time.
Definition: TStopwatch.cxx:158
Int_t fCounter
Definition: TStopwatch.h:42
static Double_t GetRealTime()
Private static method returning system realtime.
Definition: TStopwatch.cxx:139
Double_t fStopRealTime
Definition: TStopwatch.h:36
Int_t Counter() const
Definition: TStopwatch.h:52
double Double_t
Definition: RtypesCore.h:55
Double_t fStartRealTime
Definition: TStopwatch.h:35
Double_t fTotalCpuTime
Definition: TStopwatch.h:39
Mother of all ROOT objects.
Definition: TObject.h:37
void Reset()
Definition: TStopwatch.h:54
const Bool_t kTRUE
Definition: Rtypes.h:91
Double_t fStopCpuTime
Definition: TStopwatch.h:38
Stopwatch class.
Definition: TStopwatch.h:30