TDbiTimer.cxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TDbiTimer.hxx"
00017 #include <MsgFormat.h>
00018 #include <TSK_DBI_Log.hxx>
00019 #include <MsgFormat.h>
00020 using std::endl;
00021
00022 ClassImp(TDbiTimer)
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 TDbiTimer::TDbiTimer() :
00035 fCurSubWatch(0),
00036 fRowSize(0),
00037 fQueryStage(kPassive)
00038 {
00039
00040
00041
00042
00043
00044
00045
00046
00047 SK_DBI_Trace( "Creating TDbiTimer" << " ");
00048
00049 fWatch.Stop();
00050 for ( int subWatch = 0; subWatch < kMaxSubWatch; ++subWatch) {
00051 fSubWatches[subWatch].Stop();
00052 }
00053
00054 }
00055
00056
00057
00058
00059 TDbiTimer::~TDbiTimer() {
00060
00061
00062
00063
00064
00065
00066
00067
00068 SK_DBI_Trace( "Destroying TDbiTimer" << " ");
00069
00070 }
00071
00072
00073
00074 void TDbiTimer::RecBegin(string tableName, UInt_t rowSize) {
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 fQueryStage = kInitialQuery;
00086 fTableName = tableName;
00087 fRowSize = rowSize;
00088 fWatch.Start();
00089 for ( int subWatch = 0; subWatch < kMaxSubWatch; ++subWatch) {
00090
00091 fSubWatches[subWatch].Start();
00092 fSubWatches[subWatch].Stop();
00093 }
00094 if ( fCurSubWatch >= 0 ) this->StartSubWatch(0);
00095
00096 }
00097
00098
00099 void TDbiTimer::RecEnd(UInt_t numRows) {
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
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 }
00156
00157
00158 void TDbiTimer::RecMainQuery() {
00159
00160
00161
00162
00163
00164
00165 fQueryStage = kMainQuery;
00166
00167 }
00168
00169
00170 void TDbiTimer::RecFillAgg(Int_t ) {
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 }
00181
00182 void TDbiTimer::Resume() {
00183
00184
00185
00186
00187
00188
00189 if ( fCurSubWatch >= 0 ) fSubWatches[fCurSubWatch].Start(kFALSE);
00190 fWatch.Start(kFALSE);
00191 }
00192
00193
00194
00195 void TDbiTimer::StartSubWatch(UInt_t subWatch) {
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205 if ( fCurSubWatch < 0
00206 || subWatch >= kMaxSubWatch ) return;
00207
00208 fSubWatches[fCurSubWatch].Stop();
00209 fCurSubWatch = subWatch;
00210 fSubWatches[fCurSubWatch].Start(kFALSE);
00211
00212 }
00213
00214 void TDbiTimer::Suspend() {
00215
00216
00217
00218
00219
00220
00221 if ( fCurSubWatch >= 0 ) fSubWatches[fCurSubWatch].Stop();
00222 fWatch.Stop();
00223 }
00224
00225
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