Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

DbiTimer.cxx

Go to the documentation of this file.
00001 
00002 // $Id: DbiTimer.cxx,v 1.8 2003/02/27 16:16:29 west Exp $
00003 //
00004 // DbiTimer  
00005 //
00006 // Package: Dbi (Database Interface).
00007 // 
00008 // N. West 01/2002 
00009 // 
00010 // Concept: Simple timer record query progress and final times.
00011 //   
00012 // Purpose: To find out why this is all soooo sssllloooowwww!
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 //   Definition of static data members
00025 //   *********************************
00026 
00027 CVSID("$Id: DbiTimer.cxx,v 1.8 2003/02/27 16:16:29 west Exp $");
00028 
00029 // Definition of member functions (alphabetical order)
00030 // ***************************************************
00031 
00032 //.....................................................................
00033 
00034 DbiTimer::DbiTimer() :
00035 fCurSubWatch(0),
00036 fRowSize(0),
00037 fQueryStage(kPassive)
00038 {
00039 //
00040 //
00041 //  Purpose:  Default constructor
00042 //
00043 //  Contact:   N. West
00044 //
00045 
00046   LEA_CTOR    //Leak Checker
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 //  Purpose: Destructor
00064 //
00065 //  Contact:   N. West
00066 //
00067 
00068   LEA_DTOR    //Leak Checker
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 //  Purpose:  Record the start of initial query on supplied table.
00080 //
00081 //  Arguments: 
00082 //    tableName    in    Name of table.
00083 //    rowSize      in    Size of row object
00084 //
00085 //  Contact:   N. West
00086 
00087   fQueryStage = kInitialQuery;
00088   fTableName = tableName;
00089   fRowSize = rowSize;
00090   fWatch.Start();
00091   for ( int subWatch = 0; subWatch <  kMaxSubWatch; ++subWatch) {
00092     // Use Start to reset the counter (Reset doesn't do this).
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 //  Purpose:  Record the end of query.
00105 //
00106 //  Arguments: 
00107 //    numRows    in    Number of rows found in query
00108 //
00109 //  Contact:   N. West
00110 //
00111 //  Specification:-
00112 //  =============
00113 //
00114 //  o Record the end of query.  If query never reached the Main Query
00115 //    phase then quit as query must have been satisfied
00116 //    by the cache.
00117 //
00118 // o  If SubWatches enabled print them out if the main timer has 
00119 //    recorded significant activity.
00120 
00121 //  None.
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 //  Purpose:  Record the start of main query.
00165 //
00166 //  Contact:   N. West
00167 
00168   fQueryStage = kMainQuery;
00169 
00170 }
00171 //.....................................................................
00172 
00173 void DbiTimer::RecFillAgg(Int_t /* aggNo */) {
00174 //
00175 //
00176 //  Purpose:  Record filling of aggregate.
00177 //
00178 //  Arguments: 
00179 //    aggNo        in    Aggregate number.
00180 //
00181 //  Contact:   N. West
00182 
00183 }
00184 
00185 void DbiTimer::Resume() {
00186 //
00187 //
00188 //  Purpose:  Resume timer and any partial timer.
00189 //
00190 //  Contact:   N. West
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 //  Purpose:  Start specified SubWatch if SubWatch timers enabled.
00202 //
00203 //  Arguments: 
00204 //    subWatch     in    SubWatch number ( 0 .. kMaxSubWatch-1 ).
00205 //
00206 //  Contact:   N. West
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 //  Purpose:  Suspend timer and any partial timer.
00221 //
00222 //  Contact:   N. West
00223 
00224   if ( fCurSubWatch >= 0 ) fSubWatches[fCurSubWatch].Stop();
00225   fWatch.Stop();
00226 }
00227 
00228 /*    Template for New Member Function
00229 
00230 //.....................................................................
00231 
00232 DbiTimer:: {
00233 //
00234 //
00235 //  Purpose:  
00236 //
00237 //  Arguments: 
00238 //    xxxxxxxxx    in    yyyyyy
00239 //
00240 //  Return:    
00241 //
00242 //  Contact:   N. West
00243 //
00244 //  Specification:-
00245 //  =============
00246 //
00247 //  o 
00248 
00249 //  Program Notes:-
00250 //  =============
00251 
00252 //  None.
00253 
00254 
00255 }
00256 
00257 */
00258 

Generated on Mon Feb 15 11:06:35 2010 for loon by  doxygen 1.3.9.1