00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00015
00016 #include "DatabaseInterface/DbiTimer.h"
00017 #include "LeakChecker/Lea.h"
00018 #include "MessageService/MsgFormat.h"
00019 #include "MessageService/MsgService.h"
00020
00021 ClassImp(DbiTimer)
00022
00023
00024
00025
00026
00027 CVSID("$Id: DbiTimer.cxx,v 1.8 2003/02/27 16:16:29 west Exp $");
00028
00029
00030
00031
00032
00033
00034 DbiTimer::DbiTimer() :
00035 fCurSubWatch(0),
00036 fRowSize(0),
00037 fQueryStage(kPassive)
00038 {
00039
00040
00041
00042
00043
00044
00045
00046 LEA_CTOR
00047
00048 MSG("Dbi", Msg::kVerbose) << "Creating DbiTimer" << endl;
00049
00050 fWatch.Stop();
00051 for ( int subWatch = 0; subWatch < kMaxSubWatch; ++subWatch) {
00052 fSubWatches[subWatch].Stop();
00053 }
00054
00055 }
00056
00057
00058
00059
00060 DbiTimer::~DbiTimer() {
00061
00062
00063
00064
00065
00066
00067
00068 LEA_DTOR
00069
00070 MSG("Dbi", Msg::kVerbose) << "Destroying DbiTimer" << endl;
00071
00072 }
00073
00074
00075
00076 void DbiTimer::RecBegin(string tableName, UInt_t rowSize) {
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 fQueryStage = kInitialQuery;
00088 fTableName = tableName;
00089 fRowSize = rowSize;
00090 fWatch.Start();
00091 for ( int subWatch = 0; subWatch < kMaxSubWatch; ++subWatch) {
00092
00093 fSubWatches[subWatch].Start();
00094 fSubWatches[subWatch].Stop();
00095 }
00096 if ( fCurSubWatch >= 0 ) this->StartSubWatch(0);
00097
00098 }
00099
00100
00101 void DbiTimer::RecEnd(UInt_t numRows) {
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 if ( fQueryStage != kMainQuery ) return;
00124
00125 Float_t tableSize = numRows * fRowSize/1.0e+3;
00126 string units = "Kb";
00127 if ( tableSize > 1000. ) {
00128 tableSize /= 1000.;
00129 units = "Mb";
00130 }
00131 MsgFormat ffmt("%6.1f");
00132
00133 MSG("Dbi",Msg::kInfo) << "DbiTimer:" << fTableName
00134 << ": Query done. " << numRows
00135 << "rows, " << ffmt(tableSize) << units
00136 << " Cpu" << ffmt(fWatch.CpuTime())
00137 << " , elapse" << ffmt(fWatch.RealTime())
00138 << endl;
00139
00140 fWatch.Stop();
00141 fQueryStage = kPassive;
00142
00143 if ( fCurSubWatch >= 0 && fWatch.RealTime() > 5. ) {
00144 for ( int subWatch = 0; subWatch < kMaxSubWatch; ++subWatch) {
00145 static const Char_t* subWatchNames[kMaxSubWatch]
00146 = { "Query database ",
00147 "Create row objects ",
00148 "Retrieve TSQL rows ",
00149 "Fill row objects "};
00150 MSG("Dbi",Msg::kInfo)
00151 << " SubWatch " << subWatchNames[subWatch]
00152 << ": Cpu" << ffmt(fSubWatches[subWatch].CpuTime())
00153 << " , elapse" << ffmt(fSubWatches[subWatch].RealTime())
00154 << " , Starts " << fSubWatches[subWatch].Counter()
00155 << endl;
00156 }
00157 }
00158 }
00159
00160
00161 void DbiTimer::RecMainQuery() {
00162
00163
00164
00165
00166
00167
00168 fQueryStage = kMainQuery;
00169
00170 }
00171
00172
00173 void DbiTimer::RecFillAgg(Int_t ) {
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 }
00184
00185 void DbiTimer::Resume() {
00186
00187
00188
00189
00190
00191
00192 if ( fCurSubWatch >= 0 ) fSubWatches[fCurSubWatch].Start(kFALSE);
00193 fWatch.Start(kFALSE);
00194 }
00195
00196
00197
00198 void DbiTimer::StartSubWatch(UInt_t subWatch) {
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208 if ( fCurSubWatch < 0
00209 || subWatch >= kMaxSubWatch ) return;
00210
00211 fSubWatches[fCurSubWatch].Stop();
00212 fCurSubWatch = subWatch;
00213 fSubWatches[fCurSubWatch].Start(kFALSE);
00214
00215 }
00216
00217 void DbiTimer::Suspend() {
00218
00219
00220
00221
00222
00223
00224 if ( fCurSubWatch >= 0 ) fSubWatches[fCurSubWatch].Stop();
00225 fWatch.Stop();
00226 }
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258