Some more docs.
authoralpar
Mon, 26 Apr 2004 17:33:51 +0000
changeset 4254fbe868c1fb4
parent 424 f07ff78d4fad
child 426 675bfb074509
Some more docs.
Put it into the 'misc' group.
src/work/marci/time_measure.h
     1.1 --- a/src/work/marci/time_measure.h	Mon Apr 26 17:31:49 2004 +0000
     1.2 +++ b/src/work/marci/time_measure.h	Mon Apr 26 17:33:51 2004 +0000
     1.3 @@ -2,6 +2,10 @@
     1.4  #ifndef HUGO_TIME_MEASURE_H
     1.5  #define HUGO_TIME_MEASURE_H
     1.6  
     1.7 +///ingroup graphs
     1.8 +///\file
     1.9 +///\brief Tools for measuring cpu usage
    1.10 +
    1.11  #include <sys/time.h>
    1.12  #include <sys/times.h>
    1.13  #include <fstream>
    1.14 @@ -10,14 +14,10 @@
    1.15  
    1.16  namespace hugo {
    1.17  
    1.18 -//   double currTime() {
    1.19 -//     timeval tv;
    1.20 -//     //timezone tz;
    1.21 -//     gettimeofday(&tv, 0);
    1.22 -//     return double(tv.tv_sec)+double(tv.tv_usec)/1000000.0;
    1.23 -//   }
    1.24 +  /// \addtogroup misc
    1.25 +  /// @{
    1.26  
    1.27 -  /// Class to store (cpu)time instances.
    1.28 +  /// A class to store (cpu)time instances.
    1.29  
    1.30    /// This class stores five time values.
    1.31    /// - a real time
    1.32 @@ -27,7 +27,7 @@
    1.33    /// - a system cpu time of children
    1.34    ///
    1.35    /// TimeStamp's can be added to or substracted from each other and
    1.36 -  /// they can be push to a stream.
    1.37 +  /// they can be pushed to a stream.
    1.38  
    1.39    class TimeStamp
    1.40    {
    1.41 @@ -38,8 +38,7 @@
    1.42  
    1.43      tms &getTms() {return ts;}
    1.44      const tms &getTms() const {return ts;}
    1.45 -    double getRealTime() const {return real_time;}
    1.46 -    ///Read the current time values of the process.
    1.47 +    ///Read the current time values of the process
    1.48      void stamp()
    1.49      {
    1.50        timeval tv;
    1.51 @@ -47,12 +46,13 @@
    1.52        gettimeofday(&tv, 0);real_time=tv.tv_sec+double(tv.tv_usec)/1e6;
    1.53      }
    1.54    
    1.55 -    /// Constructor initializing with zero.
    1.56 +    /// Constructor initializing with zero
    1.57      TimeStamp()
    1.58      { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0; real_time=0;}
    1.59 -    ///Constructor initializing with the current time values of the process.
    1.60 +    ///Constructor initializing with the current time values of the process
    1.61      TimeStamp(void *) { stamp();}
    1.62    
    1.63 +    ///
    1.64      TimeStamp &operator+=(const TimeStamp &b)
    1.65      {
    1.66        ts.tms_utime+=b.ts.tms_utime;
    1.67 @@ -62,11 +62,13 @@
    1.68        real_time+=b.real_time;
    1.69        return *this;
    1.70      }
    1.71 +    ///
    1.72      TimeStamp operator+(const TimeStamp &b) const
    1.73      {
    1.74        TimeStamp t(*this);
    1.75        return t+=b;
    1.76      }
    1.77 +    ///
    1.78      TimeStamp &operator-=(const TimeStamp &b)
    1.79      {
    1.80        ts.tms_utime-=b.ts.tms_utime;
    1.81 @@ -76,6 +78,7 @@
    1.82        real_time-=b.real_time;
    1.83        return *this;
    1.84      }
    1.85 +    ///
    1.86      TimeStamp operator-(const TimeStamp &b) const
    1.87      {
    1.88        TimeStamp t(*this);
    1.89 @@ -91,25 +94,31 @@
    1.90    
    1.91      friend std::ostream& operator<<(std::ostream& os,const TimeStamp &t);
    1.92    
    1.93 +    ///Gives back the user time of the process
    1.94      double getUserTime() const
    1.95      {
    1.96        return double(ts.tms_utime)/sysconf(_SC_CLK_TCK);
    1.97      }
    1.98 +    ///Gives back the system time of the process
    1.99      double getSystemTime() const
   1.100      {
   1.101        return double(ts.tms_stime)/sysconf(_SC_CLK_TCK);
   1.102      }
   1.103 +    ///Gives back the user time of the process' children
   1.104      double getCUserTime() const
   1.105      {
   1.106        return double(ts.tms_cutime)/sysconf(_SC_CLK_TCK);
   1.107      }
   1.108 +    ///Gives back the user time of the process' children
   1.109      double getCSystemTime() const
   1.110      {
   1.111        return double(ts.tms_cstime)/sysconf(_SC_CLK_TCK);
   1.112      }
   1.113 +    ///Gives back the real time of the process
   1.114 +    double getRealTime() const {return real_time;}
   1.115    };
   1.116  
   1.117 -  ///Class measuring the cpu time and real time usage of the process.
   1.118 +  ///Class measuring the cpu time and real time usage of the process
   1.119    class Timer
   1.120    {
   1.121      TimeStamp start_time;
   1.122 @@ -117,10 +126,10 @@
   1.123      void _reset() {start_time.stamp();}
   1.124    
   1.125    public: 
   1.126 -    ///Constructor. It starts with zero time counters.
   1.127 +    ///Constructor. It starts with zero time counters
   1.128      Timer() {_reset();}
   1.129  
   1.130 -    ///Computes the ellapsed time.
   1.131 +    ///Computes the ellapsed time
   1.132  
   1.133      ///This conversion computes the ellapsed time
   1.134      ///since the construction of \c t or since
   1.135 @@ -132,7 +141,7 @@
   1.136        return t-start_time;
   1.137      }
   1.138  
   1.139 -    ///Resets the time counters.
   1.140 +    ///Resets the time counters
   1.141      TimeStamp reset()
   1.142      {
   1.143        TimeStamp t(start_time);
   1.144 @@ -141,7 +150,20 @@
   1.145      }
   1.146    };
   1.147  
   1.148 -  ///Prints the time counters.
   1.149 +  ///Prints the time counters
   1.150 +
   1.151 +  ///Prints the time counters in the folloing form:
   1.152 +  ///
   1.153 +  /// u: XX.XXs s: XX.XXs cu: XX.XXs cs: XX.XXs real: XX.XXs 
   1.154 +  ///
   1.155 +  /// where the values are the
   1.156 +  /// - a user cpu time,
   1.157 +  /// - a system cpu time,
   1.158 +  /// - a user cpu time of children,
   1.159 +  /// - a system cpu time of children and
   1.160 +  /// - a real time,
   1.161 +  ///
   1.162 +  ///respectively
   1.163    inline std::ostream& operator<<(std::ostream& os,const TimeStamp &t)
   1.164    {
   1.165      long cls = sysconf(_SC_CLK_TCK);
   1.166 @@ -153,6 +175,8 @@
   1.167      return os;
   1.168    }
   1.169  
   1.170 +  /// @}  
   1.171 +
   1.172  } //namespace hugo
   1.173  
   1.174  #endif //HUGO_TIME_MEASURE_H