COIN-OR::LEMON - Graph Library

Changeset 1851:78b5ea23f0f1 in lemon-0.x


Ignore:
Timestamp:
12/06/05 19:44:26 (18 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2419
Message:

Doc improvements

Location:
lemon
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lemon/counter.h

    r1847 r1851  
    9696  ///or decrement the counter using operator++ and operator--.
    9797  ///A report is automatically printed on destruction.
     98  ///\todo More doc
    9899  class Counter
    99100  {
  • lemon/time_measure.h

    r1850 r1851  
    4545  /// they can be pushed to a stream.
    4646  ///
    47   /// In most cases, perhaps \ref Timer class is what you want to use instead.
     47  /// In most cases, perhaps the \ref Timer or the \ref TimeReport
     48  /// class is what you want to use instead.
    4849  ///
    4950  ///\author Alpar Juttner
     
    194195  }
    195196 
     197  ///Prints the time counters
     198
     199  ///Prints the time counters in the following form:
     200  ///
     201  /// <tt>u: XX.XXs s: XX.XXs cu: XX.XXs cs: XX.XXs real: XX.XXs</tt>
     202  ///
     203  /// where the values are the
     204  /// \li \c u: user cpu time,
     205  /// \li \c s: system cpu time,
     206  /// \li \c cu: user cpu time of children,
     207  /// \li \c cs: system cpu time of children,
     208  /// \li \c real: real time.
     209  /// \relates TimeStamp
     210  inline std::ostream& operator<<(std::ostream& os,const TimeStamp &t)
     211  {
     212    long cls = sysconf(_SC_CLK_TCK);
     213    os << "u: " << double(t.getTms().tms_utime)/cls <<
     214      "s, s: " << double(t.getTms().tms_stime)/cls <<
     215      "s, cu: " << double(t.getTms().tms_cutime)/cls <<
     216      "s, cs: " << double(t.getTms().tms_cstime)/cls <<
     217      "s, real: " << t.realTime() << "s";
     218    return os;
     219  }
     220
    196221  ///Class for measuring the cpu time and real time usage of the process
    197222
     
    230255  ///distorted results.
    231256  ///
    232   ///The \ref Timer also counts the number of \ref start()
    233   ///executions, and is stops only after the same amount (or more)
    234   ///\ref stop() "stop()"s. This can be useful e.g. to compute the running time
    235   ///of recursive functions.
     257  ///\note If you want to measure the running time of the execution of a certain
     258  ///function, consider the usage of \ref TimeReport instead.
    236259  ///
    237260  ///\todo This shouldn't be Unix (Linux) specific.
     261  ///\sa TimeReport
    238262  ///
    239263  ///\author Alpar Juttner
     
    253277    Timer(bool run=true) :_running(run) {_reset();}
    254278
    255     ///Computes the ellapsed time
    256 
    257     ///This conversion computes the ellapsed time
     279    ///\name Control the state of the timer
     280    ///Basically a Timer can be either running or stopped,
     281    ///but it provides a bit finer control on the execution.
     282    ///The \ref Timer also counts the number of \ref start()
     283    ///executions, and is stops only after the same amount (or more)
     284    ///\ref stop() "stop()"s. This can be useful e.g. to compute the running time
     285    ///of recursive functions.
    258286    ///
    259     operator TimeStamp () const
    260     {
    261       TimeStamp t;
    262       t.stamp();
    263       return _running?t-start_time:start_time;
    264     }
     287
     288    ///@{
    265289
    266290    ///Reset and stop the time counters
     
    353377    }
    354378   
     379    ///@}
     380
     381    ///\name Query Functions for the ellapsed time
     382
     383    ///@{
     384
    355385    ///Gives back the ellapsed user time of the process
    356386    double userTime() const
     
    378408      return operator TimeStamp().realTime();
    379409    }
    380 
     410    ///Computes the ellapsed time
     411
     412    ///This conversion computes the ellapsed time, therefore you can print
     413    ///the ellapsed time like this.
     414    ///\code
     415    ///  Timer T;
     416    ///  doSomething();
     417    ///  std::cout << T << '\n';
     418    ///\endcode
     419    operator TimeStamp () const
     420    {
     421      TimeStamp t;
     422      t.stamp();
     423      return _running?t-start_time:start_time;
     424    }
     425
     426
     427    ///@}
    381428  };
    382429
     
    384431
    385432  ///Same as \ref Timer but prints a report on destruction.
    386   ///\todo Untested
     433  ///This example shows its usage.
     434  ///\code
     435  ///  void myAlg(ListGraph &g,int n)
     436  ///  {
     437  ///    TimeReport TR("Running time of myAlg: ");
     438  ///    ... //Here comes the algorithm
     439  ///  }
     440  ///\endcode
     441  ///
     442  ///\sa Timer
     443  ///\sa NoTimeReport
     444  ///\todo There is no test case for this
    387445  class TimeReport : public Timer
    388446  {
     
    391449  public:
    392450    ///\e
    393    
    394     TimeReport(std::string title,std::ostream &os,bool run)
     451
     452    ///\param title This text will be printed before the ellapsed time.
     453    ///\param os The stream to print the report to.
     454    ///\param run Sets whether the timer should start immediately.
     455
     456    TimeReport(std::string title,std::ostream &os=std::cerr,bool run=true)
    395457      : Timer(run), _title(title), _os(os){}
     458    ///\e Prints the ellapsed time on destruction.
    396459    ~TimeReport()
    397460    {
    398       _os << _title << this << std::endl;
     461      _os << _title << *this << std::endl;
    399462    }
    400463  };
    401464     
    402   ///Prints the time counters
    403 
    404   ///Prints the time counters in the following form:
    405   ///
    406   /// <tt>u: XX.XXs s: XX.XXs cu: XX.XXs cs: XX.XXs real: XX.XXs</tt>
    407   ///
    408   /// where the values are the
    409   /// \li \c u: user cpu time,
    410   /// \li \c s: system cpu time,
    411   /// \li \c cu: user cpu time of children,
    412   /// \li \c cs: system cpu time of children,
    413   /// \li \c real: real time.
    414   /// \relates TimeStamp
    415   inline std::ostream& operator<<(std::ostream& os,const TimeStamp &t)
    416   {
    417     long cls = sysconf(_SC_CLK_TCK);
    418     os << "u: " << double(t.getTms().tms_utime)/cls <<
    419       "s, s: " << double(t.getTms().tms_stime)/cls <<
    420       "s, cu: " << double(t.getTms().tms_cutime)/cls <<
    421       "s, cs: " << double(t.getTms().tms_cstime)/cls <<
    422       "s, real: " << t.realTime() << "s";
    423     return os;
    424   }
    425 
    426  
     465  ///'Do nothing' version of \ref TimeReport
     466
     467  ///\sa TimeReport
     468  ///
     469  class NoTimeReport
     470  {
     471  public:
     472    ///\e
     473    NoTimeReport(std::string title,std::ostream &os=std::cerr,bool run=true) {}
     474    ///\e Do nothing.
     475    ~NoTimeReport() {}
     476
     477    operator TimeStamp () const { return TimeStamp(); }
     478    void reset() {}
     479    void start() {}
     480    void stop() {}
     481    void halt() {}
     482    int running() { return 0; }
     483    void restart() {}
     484    double userTime() const { return 0; }
     485    double systemTime() const { return 0; }
     486    double cUserTime() const { return 0; }
     487    double cSystemTime() const { return 0; }
     488    double realTime() const { return 0; }
     489  };
     490     
    427491  ///Tool to measure the running time more exactly.
    428492 
Note: See TracChangeset for help on using the changeset viewer.