lemon/time_measure.h
branch1.3
changeset 1112 b6bad215bccd
parent 1054 c40a9d94442d
child 1143 f70f688d9ef9
equal deleted inserted replaced
20:16db4cd5cf69 21:b48041b501ef
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     2  *
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library.
     3  * This file is a part of LEMON, a generic C++ optimization library.
     4  *
     4  *
     5  * Copyright (C) 2003-2009
     5  * Copyright (C) 2003-2013
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     8  *
     9  * Permission to use, modify and distribute this software is granted
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    10  * provided that this copyright notice appears in all copies. For
    96     ///Retrieve the current output format
    96     ///Retrieve the current output format
    97     ///
    97     ///
    98     ///The output format is global for all timestamp instances.
    98     ///The output format is global for all timestamp instances.
    99     static Format format() { return _format; }
    99     static Format format() { return _format; }
   100 
   100 
   101     
   101 
   102     ///Read the current time values of the process
   102     ///Read the current time values of the process
   103     void stamp()
   103     void stamp()
   104     {
   104     {
   105 #ifndef WIN32
   105 #ifndef WIN32
   106       timeval tv;
   106       timeval tv;
   520     ///\param os The stream to print the report to.
   520     ///\param os The stream to print the report to.
   521     ///\param run Sets whether the timer should start immediately.
   521     ///\param run Sets whether the timer should start immediately.
   522     ///\param active Sets whether the report should actually be printed
   522     ///\param active Sets whether the report should actually be printed
   523     ///       on destruction.
   523     ///       on destruction.
   524     TimeReport(std::string title,std::ostream &os=std::cerr,bool run=true,
   524     TimeReport(std::string title,std::ostream &os=std::cerr,bool run=true,
   525 	       bool active=true)
   525                bool active=true)
   526       : Timer(run), _title(title), _os(os), _active(active) {}
   526       : Timer(run), _title(title), _os(os), _active(active) {}
   527     ///Destructor that prints the ellapsed time
   527     ///Destructor that prints the ellapsed time
   528     ~TimeReport()
   528     ~TimeReport()
   529     {
   529     {
   530       if(_active) _os << _title << *this << std::endl;
   530       if(_active) _os << _title << *this << std::endl;
   531     }
   531     }
   532     
   532 
   533     ///Retrieve the activity status
   533     ///Retrieve the activity status
   534 
   534 
   535     ///\e
   535     ///\e
   536     ///
   536     ///
   537     bool active() const { return _active; }
   537     bool active() const { return _active; }