Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

StDbLogger.hh

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * 00003 * $Id: StDbLogger.hh,v 1.1 2001/01/22 18:37:55 porter Exp $ 00004 * 00005 * Author: R. Jeff Porter 00006 *************************************************************************** 00007 * 00008 * Description: Records elapsed times for DBI & query calls 00009 * 00010 *************************************************************************** 00011 * 00012 * $Log: StDbLogger.hh,v $ 00013 * Revision 1.1 2001/01/22 18:37:55 porter 00014 * Update of code needed in next year running. This update has little 00015 * effect on the interface (only 1 method has been changed in the interface). 00016 * Code also preserves backwards compatibility so that old versions of 00017 * StDbLib can read new table structures. 00018 * -Important features: 00019 * a. more efficient low-level table structure (see StDbSql.cc) 00020 * b. more flexible indexing for new systems (see StDbElememtIndex.cc) 00021 * c. environment variable override KEYS for each database 00022 * d. StMessage support & clock-time logging diagnostics 00023 * -Cosmetic features 00024 * e. hid stl behind interfaces (see new *Impl.* files) to again allow rootcint access 00025 * f. removed codes that have been obsolete for awhile (e.g. db factories) 00026 * & renamed some classes for clarity (e.g. tableQuery became StDataBaseI 00027 * and mysqlAccessor became StDbSql) 00028 * 00029 **************************************************************************/ 00030 #ifndef STDBLOGGER_HH 00031 #define STDBLOGGER_HH 00032 00033 #include <sys/time.h> 00034 00035 class StDbLogger { 00036 00037 protected: 00038 00039 double mt0; 00040 double mtotalTimes; 00041 int mnTotal; 00042 00043 public: 00044 00045 StDbLogger(): mtotalTimes(0), mnTotal(0) {}; 00046 ~StDbLogger(){}; 00047 00048 void start(); 00049 double end(); 00050 00051 double getTotalTimes(); 00052 int getNumCalls(); 00053 double wallTime(); 00054 00055 }; 00056 00057 inline void StDbLogger::start(){mt0=wallTime();} 00058 inline double StDbLogger::end() { 00059 double elapsedTime=wallTime()-mt0; 00060 mtotalTimes+=elapsedTime; 00061 mnTotal++; 00062 return elapsedTime; 00063 } 00064 inline double StDbLogger::getTotalTimes() { return mtotalTimes; }; 00065 inline int StDbLogger::getNumCalls() { return mnTotal; } 00066 inline double StDbLogger::wallTime(){ 00067 struct timeval Tp; 00068 gettimeofday( &Tp, (struct timezone *) 0); 00069 // seconds + microseconds/1000000: 00070 return Tp.tv_sec + Tp.tv_usec/1000000.0; 00071 }; 00072 00073 #endif

Generated on Thu Aug 24 14:45:26 2006 for Doxygen by doxygen 1.3.7