Concept: Simple timer, record query progress and final times. More...
#include <TDbiTimer.hxx>
Public Member Functions | |
TDbiTimer () | |
virtual | ~TDbiTimer () |
void | RecBegin (string tableName, UInt_t rowSize) |
void | RecEnd (UInt_t numRows) |
void | RecFillAgg (Int_t aggNo) |
void | RecMainQuery () |
void | Resume () |
void | StartSubWatch (UInt_t subWatch) |
void | Suspend () |
Private Types | |
enum | QueryStage { kPassive, kInitialQuery, kMainQuery } |
enum | { kMaxSubWatch = 4 } |
Private Attributes | |
Int_t | fCurSubWatch |
UInt_t | fRowSize |
QueryStage | fQueryStage |
TStopwatch | fSubWatches [kMaxSubWatch] |
string | fTableName |
TStopwatch | fWatch |
Concept: Simple timer, record query progress and final times.
Purpose: To find out why this is all soooo sssllloooowwww!
Definition at line 24 of file TDbiTimer.hxx.
anonymous enum [private] |
Definition at line 49 of file TDbiTimer.hxx.
00049 { kMaxSubWatch = 4 }; // Must be > 0.
enum TDbiTimer::QueryStage [private] |
Definition at line 48 of file TDbiTimer.hxx.
00048 { kPassive, kInitialQuery, kMainQuery };
TDbiTimer::TDbiTimer | ( | ) |
TDbiTimer::~TDbiTimer | ( | ) | [virtual] |
Definition at line 59 of file TDbiTimer.cxx.
References SK_DBI_Trace.
00059 { 00060 // 00061 // 00062 // Purpose: Destructor 00063 // 00064 // Contact: N. West 00065 // 00066 00067 00068 SK_DBI_Trace( "Destroying TDbiTimer" << " "); 00069 00070 }
void TDbiTimer::RecBegin | ( | string | tableName, | |
UInt_t | rowSize | |||
) |
Definition at line 74 of file TDbiTimer.cxx.
References fCurSubWatch, fQueryStage, fRowSize, fSubWatches, fTableName, fWatch, kInitialQuery, kMaxSubWatch, and StartSubWatch().
Referenced by TDbiTimerManager::RecBegin().
00074 { 00075 // 00076 // 00077 // Purpose: Record the start of initial query on supplied table. 00078 // 00079 // Arguments: 00080 // tableName in Name of table. 00081 // rowSize in Size of row object 00082 // 00083 // Contact: N. West 00084 00085 fQueryStage = kInitialQuery; 00086 fTableName = tableName; 00087 fRowSize = rowSize; 00088 fWatch.Start(); 00089 for ( int subWatch = 0; subWatch < kMaxSubWatch; ++subWatch) { 00090 // Use Start to reset the counter (Reset doesn't do this). 00091 fSubWatches[subWatch].Start(); 00092 fSubWatches[subWatch].Stop(); 00093 } 00094 if ( fCurSubWatch >= 0 ) this->StartSubWatch(0); 00095 00096 }
void TDbiTimer::RecEnd | ( | UInt_t | numRows | ) |
Definition at line 99 of file TDbiTimer.cxx.
References fCurSubWatch, fQueryStage, fRowSize, fSubWatches, fTableName, fWatch, kMainQuery, kMaxSubWatch, kPassive, and SK_DBI_Info.
Referenced by TDbiTimerManager::RecEnd().
00099 { 00100 // 00101 // 00102 // Purpose: Record the end of query. 00103 // 00104 // Arguments: 00105 // numRows in Number of rows found in query 00106 // 00107 // Contact: N. West 00108 // 00109 // Specification:- 00110 // ============= 00111 // 00112 // o Record the end of query. If query never reached the Main Query 00113 // phase then quit as query must have been satisfied 00114 // by the cache. 00115 // 00116 // o If SubWatches enabled print them out if the main timer has 00117 // recorded significant activity. 00118 00119 // None. 00120 00121 if ( fQueryStage != kMainQuery ) return; 00122 00123 Float_t tableSize = numRows * fRowSize/1.0e+3; 00124 string units = "Kb"; 00125 if ( tableSize > 1000. ) { 00126 tableSize /= 1000.; 00127 units = "Mb"; 00128 } 00129 MsgFormat ffmt("%6.1f"); 00130 00131 SK_DBI_Info( "TDbiTimer:" << fTableName 00132 << ": Query done. " << numRows 00133 << "rows, " << ffmt(tableSize) << units 00134 << " Cpu" << ffmt(fWatch.CpuTime()) 00135 << " , elapse" << ffmt(fWatch.RealTime()) 00136 << " "); 00137 00138 fWatch.Stop(); 00139 fQueryStage = kPassive; 00140 00141 if ( fCurSubWatch >= 0 && fWatch.RealTime() > 5. ) { 00142 for ( int subWatch = 0; subWatch < kMaxSubWatch; ++subWatch) { 00143 static const Char_t* subWatchNames[kMaxSubWatch] 00144 = { "Query database ", 00145 "Create row objects ", 00146 "Retrieve TSQL rows ", 00147 "Fill row objects "}; 00148 SK_DBI_Info( " SubWatch " << subWatchNames[subWatch] 00149 << ": Cpu" << ffmt(fSubWatches[subWatch].CpuTime()) 00150 << " , elapse" << ffmt(fSubWatches[subWatch].RealTime()) 00151 << " , Starts " << fSubWatches[subWatch].Counter() 00152 << " "); 00153 } 00154 } 00155 }
void TDbiTimer::RecFillAgg | ( | Int_t | aggNo | ) |
Definition at line 170 of file TDbiTimer.cxx.
void TDbiTimer::RecMainQuery | ( | ) |
Definition at line 158 of file TDbiTimer.cxx.
References fQueryStage, and kMainQuery.
Referenced by TDbiTimerManager::RecMainQuery().
00158 { 00159 // 00160 // 00161 // Purpose: Record the start of main query. 00162 // 00163 // Contact: N. West 00164 00165 fQueryStage = kMainQuery; 00166 00167 }
void TDbiTimer::Resume | ( | ) |
Definition at line 182 of file TDbiTimer.cxx.
References fCurSubWatch, fSubWatches, and fWatch.
Referenced by TDbiTimerManager::Pop().
00182 { 00183 // 00184 // 00185 // Purpose: Resume timer and any partial timer. 00186 // 00187 // Contact: N. West 00188 00189 if ( fCurSubWatch >= 0 ) fSubWatches[fCurSubWatch].Start(kFALSE); 00190 fWatch.Start(kFALSE); 00191 }
void TDbiTimer::StartSubWatch | ( | UInt_t | subWatch | ) |
Definition at line 195 of file TDbiTimer.cxx.
References fCurSubWatch, fSubWatches, and kMaxSubWatch.
Referenced by RecBegin(), and TDbiTimerManager::StartSubWatch().
00195 { 00196 // 00197 // 00198 // Purpose: Start specified SubWatch if SubWatch timers enabled. 00199 // 00200 // Arguments: 00201 // subWatch in SubWatch number ( 0 .. kMaxSubWatch-1 ). 00202 // 00203 // Contact: N. West 00204 00205 if ( fCurSubWatch < 0 00206 || subWatch >= kMaxSubWatch ) return; 00207 00208 fSubWatches[fCurSubWatch].Stop(); 00209 fCurSubWatch = subWatch; 00210 fSubWatches[fCurSubWatch].Start(kFALSE); 00211 00212 }
void TDbiTimer::Suspend | ( | ) |
Definition at line 214 of file TDbiTimer.cxx.
References fCurSubWatch, fSubWatches, and fWatch.
Referenced by TDbiTimerManager::Push().
00214 { 00215 // 00216 // 00217 // Purpose: Suspend timer and any partial timer. 00218 // 00219 // Contact: N. West 00220 00221 if ( fCurSubWatch >= 0 ) fSubWatches[fCurSubWatch].Stop(); 00222 fWatch.Stop(); 00223 }
Int_t TDbiTimer::fCurSubWatch [private] |
Definition at line 53 of file TDbiTimer.hxx.
Referenced by RecBegin(), RecEnd(), Resume(), StartSubWatch(), and Suspend().
QueryStage TDbiTimer::fQueryStage [private] |
Definition at line 55 of file TDbiTimer.hxx.
Referenced by RecBegin(), RecEnd(), and RecMainQuery().
UInt_t TDbiTimer::fRowSize [private] |
Definition at line 54 of file TDbiTimer.hxx.
Referenced by RecBegin(), and RecEnd().
TStopwatch TDbiTimer::fSubWatches[kMaxSubWatch] [private] |
Definition at line 56 of file TDbiTimer.hxx.
Referenced by RecBegin(), RecEnd(), Resume(), StartSubWatch(), and Suspend().
string TDbiTimer::fTableName [private] |
Definition at line 57 of file TDbiTimer.hxx.
Referenced by RecBegin(), and RecEnd().
TStopwatch TDbiTimer::fWatch [private] |
Definition at line 58 of file TDbiTimer.hxx.
Referenced by RecBegin(), RecEnd(), Resume(), and Suspend().