00001 /////////////////////////////////////////////////////////////////////// 00002 // $Id: TDbiTimerManager.cxx,v 1.1 2011/01/18 05:49:20 finch Exp $ 00003 // 00004 // TDbiTimerManager 00005 // 00006 // Package: TDbi (Database Interface). 00007 // 00008 // N. West 01/2002 00009 // 00010 // Concept: Manager of a set of simple timers. 00011 // 00012 // Purpose: To find out why this is all soooo sssllloooowwww! 00013 // 00014 /////////////////////////////////////////////////////////////////////// 00015 00016 #include "TDbiTimer.hxx" 00017 #include "TDbiTimerManager.hxx" 00018 #include <MsgFormat.h> 00019 #include <TSK_DBI_Log.hxx> 00020 #include <MsgFormat.h> 00021 using std::endl; 00022 00023 ClassImp(TDbiTimerManager) 00024 00025 00026 // Definition of static data members 00027 // ********************************* 00028 00029 00030 TDbiTimerManager TDbiTimerManager::gTimerManager; 00031 00032 // Definition of member functions (alphabetical order) 00033 // *************************************************** 00034 00035 //..................................................................... 00036 00037 TDbiTimerManager::TDbiTimerManager() : 00038 fEnabled(kTRUE) 00039 { 00040 // 00041 // 00042 // Purpose: Default constructor 00043 // 00044 // Contact: N. West 00045 // 00046 00047 00048 SK_DBI_Trace( "Creating TDbiTimerManager" << " "); 00049 00050 } 00051 00052 //..................................................................... 00053 00054 TDbiTimerManager::~TDbiTimerManager() { 00055 // 00056 // 00057 // Purpose: Destructor 00058 // 00059 // Contact: N. West 00060 // 00061 00062 00063 SK_DBI_Trace( "Destroying TDbiTimerManager" << " "); 00064 while ( this->GetCurrent() ) this->Pop(); 00065 00066 } 00067 00068 //..................................................................... 00069 00070 TDbiTimer* TDbiTimerManager::GetCurrent() { 00071 // 00072 // 00073 // Purpose: Get the current timer if any. 00074 // 00075 // Return: Curent timer or null if none. 00076 // 00077 // Contact: N. West 00078 00079 return fTimers.empty() ? 0 : *(fTimers.begin()); 00080 } 00081 //..................................................................... 00082 00083 TDbiTimer* TDbiTimerManager::Pop() { 00084 // 00085 // 00086 // Purpose: Remove the most recent timer, and resume the previous. 00087 // 00088 // Return: Previous timer (if any). 00089 // 00090 00091 if ( fTimers.empty() ) return 0; 00092 00093 TDbiTimer* timer = this->GetCurrent(); 00094 delete timer; 00095 timer = 0; 00096 fTimers.pop_front(); 00097 timer = this->GetCurrent(); 00098 if ( timer ) timer->Resume(); 00099 return timer; 00100 00101 } 00102 00103 //..................................................................... 00104 00105 TDbiTimer* TDbiTimerManager::Push() { 00106 // 00107 // 00108 // Purpose: Suspend current time and add new timer to stack. 00109 // 00110 // Return: New timer. 00111 // 00112 00113 TDbiTimer* timer = this->GetCurrent(); 00114 if ( timer ) timer->Suspend(); 00115 fTimers.push_front(new TDbiTimer); 00116 return this->GetCurrent(); 00117 00118 } 00119 00120 //..................................................................... 00121 00122 void TDbiTimerManager::RecBegin(string tableName, UInt_t rowSize) { 00123 // 00124 // 00125 // Purpose: Record the start of initial query on supplied table. 00126 // 00127 // Arguments: 00128 // tableName in Name of table. 00129 // rowSize in Size of row object 00130 // 00131 // Contact: N. West 00132 00133 // Suspend current timer, if any, and start a new one. 00134 00135 if ( ! fEnabled ) return; 00136 TDbiTimer* timer = this->Push(); 00137 timer->RecBegin(tableName, rowSize); 00138 } 00139 //..................................................................... 00140 00141 void TDbiTimerManager::RecEnd(UInt_t numRows) { 00142 // 00143 // 00144 // Purpose: Record the end of query. 00145 // 00146 // Arguments: 00147 // numRows in Number of rows found in query 00148 // 00149 // Contact: N. West 00150 00151 if ( ! fEnabled ) return; 00152 00153 // Terminate the current timer and resume the previous one. 00154 00155 TDbiTimer* timer = this->GetCurrent(); 00156 if ( timer ) timer->RecEnd(numRows); 00157 timer = this->Pop(); 00158 00159 } 00160 00161 //..................................................................... 00162 00163 void TDbiTimerManager::RecFillAgg(Int_t /* aggNo */) { 00164 // 00165 // 00166 // Purpose: Record filling of aggregate. 00167 // 00168 // Arguments: 00169 // aggNo in Aggregate number. 00170 // 00171 // Contact: N. West 00172 00173 if ( ! fEnabled ) return; 00174 00175 // Currently a no-op. 00176 00177 } 00178 00179 //..................................................................... 00180 00181 void TDbiTimerManager::RecMainQuery() { 00182 // 00183 // 00184 // Purpose: Record the start of main query. 00185 // 00186 // Contact: N. West 00187 00188 if ( ! fEnabled ) return; 00189 TDbiTimer* timer = this->GetCurrent(); 00190 if ( timer ) timer->RecMainQuery(); 00191 00192 } 00193 00194 //..................................................................... 00195 00196 void TDbiTimerManager::StartSubWatch(UInt_t subWatch) { 00197 // 00198 // 00199 // Purpose: Start specified SubWatch if SubWatch timers enabled. 00200 // 00201 // Arguments: 00202 // subWatch in SubWatch number ( 0 .. kMaxSubWatch-1 ). 00203 // 00204 // Contact: N. West 00205 00206 if ( ! fEnabled ) return; 00207 TDbiTimer* timer = this->GetCurrent(); 00208 if ( timer ) timer->StartSubWatch(subWatch); 00209 00210 } 00211 00212 /* Template for New Member Function 00213 00214 //..................................................................... 00215 00216 TDbiTimerManager:: { 00217 // 00218 // 00219 // Purpose: 00220 // 00221 // Arguments: 00222 // xxxxxxxxx in yyyyyy 00223 // 00224 // Return: 00225 // 00226 // Contact: N. West 00227 // 00228 // Specification:- 00229 // ============= 00230 // 00231 // o 00232 00233 // Program Notes:- 00234 // ============= 00235 00236 // None. 00237 00238 00239 } 00240 00241 */ 00242 00243 00244