TStopwatch.h

Go to the documentation of this file.
00001 // @(#)root/base:$Id: TStopwatch.h 20877 2007-11-19 11:17:07Z rdm $
00002 // Author: Fons Rademakers   11/10/95
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TStopwatch
00013 #define ROOT_TStopwatch
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TStopwatch                                                           //
00019 //                                                                      //
00020 // Stopwatch class. This class returns the real and cpu time between    //
00021 // the start and stop events.                                           //
00022 //                                                                      //
00023 //////////////////////////////////////////////////////////////////////////
00024 
00025 #ifndef ROOT_TObject
00026 #include "TObject.h"
00027 #endif
00028 
00029 
00030 class TStopwatch : public TObject {
00031 
00032 private:
00033    enum EState { kUndefined, kStopped, kRunning };
00034 
00035    Double_t     fStartRealTime;   //wall clock start time
00036    Double_t     fStopRealTime;    //wall clock stop time
00037    Double_t     fStartCpuTime;    //cpu start time
00038    Double_t     fStopCpuTime;     //cpu stop time
00039    Double_t     fTotalCpuTime;    //total cpu time
00040    Double_t     fTotalRealTime;   //total real time
00041    EState       fState;           //stopwatch state
00042    Int_t        fCounter;         //number of times the stopwatch was started
00043 
00044    static Double_t GetRealTime();
00045    static Double_t GetCPUTime();
00046 
00047 public:
00048    TStopwatch();
00049    void        Start(Bool_t reset = kTRUE);
00050    void        Stop();
00051    void        Continue();
00052    Int_t       Counter() const { return fCounter; }
00053    Double_t    RealTime();
00054    void        Reset() { ResetCpuTime(); ResetRealTime(); }
00055    void        ResetCpuTime(Double_t time = 0) { Stop();  fTotalCpuTime = time; }
00056    void        ResetRealTime(Double_t time = 0) { Stop(); fTotalRealTime = time; }
00057    Double_t    CpuTime();
00058    void        Print(Option_t *option="") const;
00059 
00060    ClassDef(TStopwatch,1)  //A stopwatch which times real and cpu time
00061 };
00062 
00063 #endif

Generated on Tue Jul 5 14:10:30 2011 for ROOT_528-00b_version by  doxygen 1.5.1