ROOT logo
// @(#)root/base:$Id: TStopwatch.h 20877 2007-11-19 11:17:07Z rdm $
// Author: Fons Rademakers   11/10/95

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TStopwatch
#define ROOT_TStopwatch


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TStopwatch                                                           //
//                                                                      //
// Stopwatch class. This class returns the real and cpu time between    //
// the start and stop events.                                           //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TObject
#include "TObject.h"
#endif


class TStopwatch : public TObject {

private:
   enum EState { kUndefined, kStopped, kRunning };

   Double_t     fStartRealTime;   //wall clock start time
   Double_t     fStopRealTime;    //wall clock stop time
   Double_t     fStartCpuTime;    //cpu start time
   Double_t     fStopCpuTime;     //cpu stop time
   Double_t     fTotalCpuTime;    //total cpu time
   Double_t     fTotalRealTime;   //total real time
   EState       fState;           //stopwatch state
   Int_t        fCounter;         //number of times the stopwatch was started

   static Double_t GetRealTime();
   static Double_t GetCPUTime();

public:
   TStopwatch();
   void        Start(Bool_t reset = kTRUE);
   void        Stop();
   void        Continue();
   Int_t       Counter() const { return fCounter; }
   Double_t    RealTime();
   void        Reset() { ResetCpuTime(); ResetRealTime(); }
   void        ResetCpuTime(Double_t time = 0) { Stop();  fTotalCpuTime = time; }
   void        ResetRealTime(Double_t time = 0) { Stop(); fTotalRealTime = time; }
   Double_t    CpuTime();
   void        Print(Option_t *option="") const;

   ClassDef(TStopwatch,1)  //A stopwatch which times real and cpu time
};

#endif
 TStopwatch.h:1
 TStopwatch.h:2
 TStopwatch.h:3
 TStopwatch.h:4
 TStopwatch.h:5
 TStopwatch.h:6
 TStopwatch.h:7
 TStopwatch.h:8
 TStopwatch.h:9
 TStopwatch.h:10
 TStopwatch.h:11
 TStopwatch.h:12
 TStopwatch.h:13
 TStopwatch.h:14
 TStopwatch.h:15
 TStopwatch.h:16
 TStopwatch.h:17
 TStopwatch.h:18
 TStopwatch.h:19
 TStopwatch.h:20
 TStopwatch.h:21
 TStopwatch.h:22
 TStopwatch.h:23
 TStopwatch.h:24
 TStopwatch.h:25
 TStopwatch.h:26
 TStopwatch.h:27
 TStopwatch.h:28
 TStopwatch.h:29
 TStopwatch.h:30
 TStopwatch.h:31
 TStopwatch.h:32
 TStopwatch.h:33
 TStopwatch.h:34
 TStopwatch.h:35
 TStopwatch.h:36
 TStopwatch.h:37
 TStopwatch.h:38
 TStopwatch.h:39
 TStopwatch.h:40
 TStopwatch.h:41
 TStopwatch.h:42
 TStopwatch.h:43
 TStopwatch.h:44
 TStopwatch.h:45
 TStopwatch.h:46
 TStopwatch.h:47
 TStopwatch.h:48
 TStopwatch.h:49
 TStopwatch.h:50
 TStopwatch.h:51
 TStopwatch.h:52
 TStopwatch.h:53
 TStopwatch.h:54
 TStopwatch.h:55
 TStopwatch.h:56
 TStopwatch.h:57
 TStopwatch.h:58
 TStopwatch.h:59
 TStopwatch.h:60
 TStopwatch.h:61
 TStopwatch.h:62
 TStopwatch.h:63