Index: lemon/time_measure.h
===================================================================
--- lemon/time_measure.h	(revision 1689)
+++ lemon/time_measure.h	(revision 1780)
@@ -67,4 +67,7 @@
     const rtms &getTms() const {return ts;}
 
+    void _reset() 
+    { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0; real_time=0;}
+
   public:
 
@@ -81,8 +84,11 @@
     /// Constructor initializing with zero
     TimeStamp()
-    { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0; real_time=0;}
+    { _reset(); }
     ///Constructor initializing with the current time values of the process
     TimeStamp(void *) { stamp();}
   
+    ///Set every time value to zero
+    TimeStamp &reset() {_reset();return *this;}
+
     ///\e
     TimeStamp &operator+=(const TimeStamp &b)
@@ -118,6 +124,4 @@
     }
     ///\e
-
-    ///\bug operator * and / gives rounded values!
     TimeStamp &operator*=(double b)
     {
@@ -181,5 +185,5 @@
       return double(ts.tms_cstime)/sysconf(_SC_CLK_TCK);
     }
-    ///Gives back the real time of the process
+    ///Gives back the real time
     double realTime() const {return real_time;}
   };
@@ -190,7 +194,7 @@
   }
   
-  ///Class measuring the cpu time and real time usage of the process
-
-  ///Class measuring the cpu time and real time usage of the process.
+  ///Class for measuring the cpu time and real time usage of the process
+
+  ///Class for measuring the cpu time and real time usage of the process.
   ///It is quite easy-to-use, here is a short example.
   ///\code
@@ -215,4 +219,19 @@
   ///\endcode
   ///
+  ///The \ref Timer can also be \ref stop() "stopped" and
+  ///\ref start() "started" again, so it is easy to compute collected
+  ///running times.
+  ///
+  ///\warning Depending on the operation system and its actual configuration
+  ///the time counters have a certain (relatively big) granularity.
+  ///Therefore this tool is not appropriate to measure very short times.
+  ///Also, if you start and stop the timer very frequently, it could lead
+  ///distorted results.
+  ///
+  ///The \ref Timer also counts the number of \ref start()
+  ///executions, and is stops only after the same amount (or more)
+  ///\ref stop() "stop()"s. This can be useful e.g. to compute the running time
+  ///of recursive functions.
+  ///
   ///\todo This shouldn't be Unix (Linux) specific.
   ///
@@ -220,22 +239,26 @@
   class Timer
   {
-    TimeStamp start_time;
-
-    void _reset() {start_time.stamp();}
+    int running; //Timer is running iff running>0; (running>=0 always holds)
+    TimeStamp start_time; //This is the relativ start-time if the timer
+                          //is running, the collected running time otherwise.
+    
+    void _reset() {if(running) start_time.stamp(); else start_time.reset();}
   
   public: 
-    ///Constructor. It starts with zero time counters
-    Timer() {_reset();}
+    ///Constructor.
+
+    ///\param _running indicates whether or not the timer starts immediately.
+    ///
+    Timer(bool _running=true) :running(_running) {_reset();}
 
     ///Computes the ellapsed time
 
     ///This conversion computes the ellapsed time
-    ///since the construction of \c t or since
-    ///the last \c t.reset().
+    ///
     operator TimeStamp () const
     {
       TimeStamp t;
       t.stamp();
-      return t-start_time;
+      return running?t-start_time:start_time;
     }
 
@@ -249,5 +272,35 @@
     }
 
-
+    ///Start the time counters
+    
+    ///This function starts the time counters.
+    ///
+    ///If the timer is started more than ones, it will remain running
+    ///until the same amount of \ref stop() is called.
+    ///\sa stop()
+    void start() 
+    {
+      if(running) running++;
+      else {
+	TimeStamp t;
+	t.stamp();
+	start_time=t-start_time;
+      }
+    }
+    
+    ///Stop the time counters
+
+    ///This function stops the time counters.
+    ///
+    ///\sa stop()
+    void stop() 
+    {
+      if(running && !--running) {
+	TimeStamp t;
+	t.stamp();
+	start_time=t-start_time;
+      }
+    }
+    
     ///Gives back the ellapsed user time of the process
     double userTime() const
@@ -270,5 +323,5 @@
       return operator TimeStamp().cSystemTime();
     }
-    ///Gives back the ellapsed real time of the process
+    ///Gives back the ellapsed real time
     double realTime() const
     {
@@ -307,5 +360,5 @@
   ///This function calls \c f several times and returns the average
   ///running time. The number of the executions will be choosen in such a way
-  ///that the full running time will be roughly between \c min_time
+  ///that the full real running time will be roughly between \c min_time
   ///and <tt>2*min_time</tt>.
   ///\param f the function object to be measured.
