00001 //--------------------------------------------------------------- 00002 // Go4 Release Package v2.10-5 (build 21005) 00003 // 03-Nov-2005 00004 //--------------------------------------------------------------- 00005 // The GSI Online Offline Object Oriented (Go4) Project 00006 // Experiment Data Processing at DVEE department, GSI 00007 //--------------------------------------------------------------- 00008 // 00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI 00010 // Planckstr. 1, 64291 Darmstadt, Germany 00011 //Contact: http://go4.gsi.de 00012 //---------------------------------------------------------------- 00013 //This software can be used under the license agreements as stated 00014 //in Go4License.txt file which is part of the distribution. 00015 //---------------------------------------------------------------- 00016 #ifndef PROFILE_TIMER_H 00017 #define PROFILE_TIMER_H 00018 00019 #include "TObject.h" 00020 00021 #ifndef __CINT__ 00022 #include <sys/time.h> 00023 #include <sys/resource.h> 00024 #else 00025 struct timeval; 00026 struct rusage; 00027 #endif 00028 00029 #define ONE_SECOND_IN_USECS 1000000L 00030 00031 class TGo4ProfileTimer { 00032 public: 00033 00034 class TGo4ElapsedTime { 00035 public: 00036 TGo4ElapsedTime(); 00037 virtual ~TGo4ElapsedTime() {} 00038 00039 Double_t fdRealTime; 00040 Double_t fdUserTime; 00041 Double_t fdSystemTime; 00042 }; 00043 00044 00045 typedef rusage Rusage; 00046 typedef TGo4ProfileTimer::TGo4ElapsedTime TGo4ElapsedTime; 00047 00048 // = Initialization and termination methods. 00049 TGo4ProfileTimer (void); 00050 // Default constructor. 00051 00052 virtual ~TGo4ProfileTimer (void); 00053 // Shutdown the timer. 00054 00055 // = Timer methods. 00056 Int_t Start(void); 00057 // Activate the timer. 00058 00059 Int_t Stop(void); 00060 // Stop the timer. 00061 00062 // = Resource utilization methods. 00063 Int_t ElapsedTime(TGo4ElapsedTime &et); 00064 // Compute the time elapsed since <start>. 00065 00066 void ElapsedRusage (TGo4ProfileTimer::Rusage &rusage); 00067 // Compute the amount of resource utilization since the start time. 00068 00069 void GetRusage (TGo4ProfileTimer::Rusage &rusage); 00070 // Return the resource utilization (don't recompute it). 00071 00072 void Dump (void) const; 00073 // Dump the state of an object. 00074 00075 void Resume (void); 00076 // Print the timing. 00077 00078 void Memory (void); 00079 // Print the memory consumption etc. 00080 00081 private: 00082 void ComputeTimes (TGo4ElapsedTime &et); 00083 // Compute how much time has elapsed. 00084 00085 TGo4ProfileTimer::Rusage fxBeginUsage; 00086 // Keep track of the starting resource utilization. 00087 00088 TGo4ProfileTimer::Rusage fxEndUsage; 00089 // Keep track of the ending resource utilization. 00090 00091 TGo4ProfileTimer::Rusage fxLastUsage; 00092 // Keep track of the last rusage for incremental timing. 00093 00094 void Subtract (timeval &tdiff, timeval &t0, timeval &t1); 00095 // Substract two timestructs and store their difference. 00096 00097 timeval fxBeginTime; 00098 // Keep track of the beginning time. 00099 00100 timeval fxEndTime; 00101 // Keep track of the ending time. 00102 00103 timeval fxLastTime; 00104 // Keep track of the last time for incremental timing. 00105 00106 ClassDef(TGo4ProfileTimer, 1) 00107 }; 00108 00109 #endif 00110 00111 //----------------------------END OF GO4 SOURCE FILE ---------------------