Logo ROOT  
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 #include "TObject.h"
26 
27 
28 class TStopwatch : public TObject {
29 
30 private:
32 
33  Double_t fStartRealTime; //wall clock start time
34  Double_t fStopRealTime; //wall clock stop time
35  Double_t fStartCpuTime; //cpu start time
36  Double_t fStopCpuTime; //cpu stop time
37  Double_t fTotalCpuTime; //total cpu time
38  Double_t fTotalRealTime; //total real time
39  EState fState; //stopwatch state
40  Int_t fCounter; //number of times the stopwatch was started
41 
42  static Double_t GetRealTime();
43  static Double_t GetCPUTime();
44 
45 public:
46  TStopwatch();
47  void Start(Bool_t reset = kTRUE);
48  void Stop();
49  void Continue();
50  Int_t Counter() const { return fCounter; }
52  void Reset() { ResetCpuTime(); ResetRealTime(); }
53  void ResetCpuTime(Double_t time = 0) { Stop(); fTotalCpuTime = time; }
54  void ResetRealTime(Double_t time = 0) { Stop(); fTotalRealTime = time; }
55  Double_t CpuTime();
56  void Print(Option_t *option="") const;
57 
58  ClassDef(TStopwatch,1) //A stopwatch which times real and cpu time
59 };
60 
61 #endif
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TStopwatch::Continue
void Continue()
Resume a stopped stopwatch.
Definition: TStopwatch.cxx:93
Option_t
const char Option_t
Definition: RtypesCore.h:66
TStopwatch::fTotalCpuTime
Double_t fTotalCpuTime
Definition: TStopwatch.h:37
TStopwatch::fStopRealTime
Double_t fStopRealTime
Definition: TStopwatch.h:34
TStopwatch::kStopped
@ kStopped
Definition: TStopwatch.h:31
TStopwatch::Counter
Int_t Counter() const
Definition: TStopwatch.h:50
TStopwatch::fStopCpuTime
Double_t fStopCpuTime
Definition: TStopwatch.h:36
TStopwatch::EState
EState
Definition: TStopwatch.h:31
bool
TStopwatch::fStartRealTime
Double_t fStartRealTime
Definition: TStopwatch.h:33
TStopwatch::RealTime
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
TStopwatch::Print
void Print(Option_t *option="") const
Print the real and cpu time passed between the start and stop events.
Definition: TStopwatch.cxx:219
TStopwatch::fState
EState fState
Definition: TStopwatch.h:39
TStopwatch::Reset
void Reset()
Definition: TStopwatch.h:52
TStopwatch::ResetCpuTime
void ResetCpuTime(Double_t time=0)
Definition: TStopwatch.h:53
TStopwatch::ResetRealTime
void ResetRealTime(Double_t time=0)
Definition: TStopwatch.h:54
TStopwatch::fStartCpuTime
Double_t fStartCpuTime
Definition: TStopwatch.h:35
TStopwatch::Start
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Definition: TStopwatch.cxx:58
TStopwatch::CpuTime
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
TStopwatch::fTotalRealTime
Double_t fTotalRealTime
Definition: TStopwatch.h:38
Double_t
double Double_t
Definition: RtypesCore.h:59
TObject.h
TStopwatch
Stopwatch class.
Definition: TStopwatch.h:28
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TStopwatch::kRunning
@ kRunning
Definition: TStopwatch.h:31
TStopwatch::TStopwatch
TStopwatch()
Create a stopwatch and start it.
Definition: TStopwatch.cxx:39
TStopwatch::fCounter
Int_t fCounter
Definition: TStopwatch.h:40
TStopwatch::kUndefined
@ kUndefined
Definition: TStopwatch.h:31
TStopwatch::Stop
void Stop()
Stop the stopwatch.
Definition: TStopwatch.cxx:77
TStopwatch::GetRealTime
static Double_t GetRealTime()
Private static method returning system realtime.
Definition: TStopwatch.cxx:139
int
TStopwatch::GetCPUTime
static Double_t GetCPUTime()
Private static method returning system CPU time.
Definition: TStopwatch.cxx:158