Documentation.
authoralpar
Thu, 15 Apr 2004 06:49:49 +0000
changeset 32763c138adc477
parent 326 e2f00e438c31
child 328 e2dd93586ebf
Documentation.
src/work/marci/time_measure.h
     1.1 --- a/src/work/marci/time_measure.h	Thu Apr 15 05:51:12 2004 +0000
     1.2 +++ b/src/work/marci/time_measure.h	Thu Apr 15 06:49:49 2004 +0000
     1.3 @@ -17,6 +17,18 @@
     1.4  //     return double(tv.tv_sec)+double(tv.tv_usec)/1000000.0;
     1.5  //   }
     1.6  
     1.7 +  /// Class to store (cpu)time instances.
     1.8 +
     1.9 +  /// This class stores five time values.
    1.10 +  /// - a real time
    1.11 +  /// - a user cpu time
    1.12 +  /// - a system cpu time
    1.13 +  /// - a user cpu time of children
    1.14 +  /// - a system cpu time of children
    1.15 +  ///
    1.16 +  /// TimeStamp's can be added to or substracted from each other and
    1.17 +  /// they can be push to a stream.
    1.18 +
    1.19    class TimeStamp
    1.20    {
    1.21      tms ts;
    1.22 @@ -27,6 +39,7 @@
    1.23      tms &getTms() {return ts;}
    1.24      const tms &getTms() const {return ts;}
    1.25      double getRealTime() const {return real_time;}
    1.26 +    ///Read the current time values of the process.
    1.27      void stamp()
    1.28      {
    1.29        timeval tv;
    1.30 @@ -34,9 +47,10 @@
    1.31        gettimeofday(&tv, 0);real_time=tv.tv_sec+double(tv.tv_usec)/1e6;
    1.32      }
    1.33    
    1.34 +    /// Constructor initializing with zero.
    1.35      TimeStamp()
    1.36      { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0; real_time=0;}
    1.37 -  
    1.38 +    ///Constructor initializing with the current time values of the process.
    1.39      TimeStamp(void *) { stamp();}
    1.40    
    1.41      TimeStamp &operator+=(const TimeStamp &b)
    1.42 @@ -68,6 +82,7 @@
    1.43        return t-=b;
    1.44      }
    1.45  
    1.46 +    ///The time ellapsed since the last call of stamp()
    1.47      TimeStamp ellapsed() const
    1.48      {
    1.49        TimeStamp t(NULL);
    1.50 @@ -94,6 +109,7 @@
    1.51      }
    1.52    };
    1.53  
    1.54 +  ///Class measuring the cpu time and real time usage of the process.
    1.55    class Timer
    1.56    {
    1.57      TimeStamp start_time;
    1.58 @@ -101,8 +117,14 @@
    1.59      void _reset() {start_time.stamp();}
    1.60    
    1.61    public: 
    1.62 +    ///Constructor. It starts with zero time counters.
    1.63      Timer() {_reset();}
    1.64  
    1.65 +    ///Computes the ellapsed time.
    1.66 +
    1.67 +    ///This conversion computes the ellapsed time
    1.68 +    ///since the construction of \c t or since
    1.69 +    ///the last \c t.reset().
    1.70      operator TimeStamp ()
    1.71      {
    1.72        TimeStamp t;
    1.73 @@ -110,6 +132,7 @@
    1.74        return t-start_time;
    1.75      }
    1.76  
    1.77 +    ///Resets the time counters.
    1.78      TimeStamp reset()
    1.79      {
    1.80        TimeStamp t(start_time);
    1.81 @@ -118,6 +141,7 @@
    1.82      }
    1.83    };
    1.84  
    1.85 +  ///Prints the time counters.
    1.86    inline std::ostream& operator<<(std::ostream& os,const TimeStamp &t)
    1.87    {
    1.88      long cls = sysconf(_SC_CLK_TCK);