XrdMonTimer.hh

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*                                                                           */
00003 /*                              XrdMonTimer.hh                               */
00004 /*                                                                           */
00005 /* (c) 2005 by the Board of Trustees of the Leland Stanford, Jr., University */
00006 /*                            All Rights Reserved                            */
00007 /*       Produced by Jacek Becla for Stanford University under contract      */
00008 /*              DE-AC02-76SF00515 with the Department of Energy              */
00009 /*****************************************************************************/
00010 
00011 // $Id: XrdMonTimer.hh 22437 2008-03-04 14:35:16Z rdm $
00012 
00013 #ifndef XRDMONTIMER_HH
00014 #define XRDMONTIMER_HH
00015 
00016 #include "sys/time.h"
00017 
00018 class XrdMonTimer {
00019 public:
00020     XrdMonTimer() { reset(); }    
00021 
00022     inline void reset();                  // resets the counter
00023 
00024     // working with elapsed time
00025     inline int  start();                  // starts the timer
00026     inline double stop();                 // stops the timer, returns elapsed time
00027     inline double getElapsed() const;     // returns elapsed time
00028 
00029     void printElapsed(const char* str);
00030     // for debugging only
00031     void printAll() const;
00032 
00033 private:
00034     // modifiers
00035     inline void resetTBeg();
00036     inline void resetTElapsed();
00037 
00038     inline double calcElapsed();       // calculates, sets, and returns total elapsed time
00039 
00040     // selectors
00041     inline int timerOn() const;
00042     inline int isOn(const struct timeval& t) const;
00043 
00044     inline double calcDif(const struct timeval& start, 
00045                           const struct timeval& stop) const;
00046 
00047     void printOne(const timeval& t, const char* prefix=0) const;
00048 
00049     double convert2Double(const timeval& t) const;
00050 
00051 private:
00052     struct timeval _tbeg;       // most recent "start"
00053     double _elapsed;   // elapsed time between all "starts" and "stops",
00054        // excluding most recent "start" which has no corresponding "stop"
00055 };
00056 
00057 #include "XrdMonTimer.icc"
00058 
00059 
00060 #endif /* XRDMONTIMER_HH */
00061 

Generated on Tue Jul 5 14:46:43 2011 for ROOT_528-00b_version by  doxygen 1.5.1