Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:30:20

0001 // @(#)root/base:$Id$
0002 // Author: Fons Rademakers   11/10/95
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TStopwatch
0013 #define ROOT_TStopwatch
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TStopwatch                                                           //
0019 //                                                                      //
0020 // Stopwatch class. This class returns the real and cpu time between    //
0021 // the start and stop events.                                           //
0022 //                                                                      //
0023 //////////////////////////////////////////////////////////////////////////
0024 
0025 #include "TObject.h"
0026 
0027 
0028 class TStopwatch : public TObject {
0029 
0030 private:
0031    enum EState { kUndefined, kStopped, kRunning };
0032 
0033    Double_t     fStartRealTime;   //wall clock start time
0034    Double_t     fStopRealTime;    //wall clock stop time
0035    Double_t     fStartCpuTime;    //cpu start time
0036    Double_t     fStopCpuTime;     //cpu stop time
0037    Double_t     fTotalCpuTime;    //total cpu time
0038    Double_t     fTotalRealTime;   //total real time
0039    EState       fState;           //stopwatch state
0040    Int_t        fCounter;         //number of times the stopwatch was started
0041 
0042    static Double_t GetRealTime();
0043    static Double_t GetCPUTime();
0044 
0045 public:
0046    TStopwatch();
0047    void        Start(Bool_t reset = kTRUE);
0048    void        Stop();
0049    void        Continue();
0050    Int_t       Counter() const { return fCounter; }
0051    Double_t    RealTime();
0052    void        Reset() { ResetCpuTime(); ResetRealTime(); }
0053    void        ResetCpuTime(Double_t time = 0) { Stop();  fTotalCpuTime = time; }
0054    void        ResetRealTime(Double_t time = 0) { Stop(); fTotalRealTime = time; }
0055    Double_t    CpuTime();
0056    void        Print(Option_t *option="") const override;
0057 
0058    ClassDefOverride(TStopwatch,1)  //A stopwatch which times real and cpu time
0059 };
0060 
0061 #endif