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

DbiTimerManager.cxx

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

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