lemon/time_measure.h
changeset 783 ef88c0a30f85
parent 548 94387da47f79
child 786 e20173729589
     1.1 --- a/lemon/time_measure.h	Mon Jan 12 23:11:39 2009 +0100
     1.2 +++ b/lemon/time_measure.h	Thu Nov 05 15:48:01 2009 +0100
     1.3 @@ -24,11 +24,9 @@
     1.4  ///\brief Tools for measuring cpu usage
     1.5  
     1.6  #ifdef WIN32
     1.7 -#define WIN32_LEAN_AND_MEAN
     1.8 -#define NOMINMAX
     1.9 -#include <windows.h>
    1.10 -#include <cmath>
    1.11 +#include <lemon/bits/windows.h>
    1.12  #else
    1.13 +#include <unistd.h>
    1.14  #include <sys/times.h>
    1.15  #include <sys/time.h>
    1.16  #endif
    1.17 @@ -87,26 +85,7 @@
    1.18        cutime=ts.tms_cutime/tck;
    1.19        cstime=ts.tms_cstime/tck;
    1.20  #else
    1.21 -      static const double ch = 4294967296.0e-7;
    1.22 -      static const double cl = 1.0e-7;
    1.23 -
    1.24 -      FILETIME system;
    1.25 -      GetSystemTimeAsFileTime(&system);
    1.26 -      rtime = ch * system.dwHighDateTime + cl * system.dwLowDateTime;
    1.27 -
    1.28 -      FILETIME create, exit, kernel, user;
    1.29 -      if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) {
    1.30 -        utime = ch * user.dwHighDateTime + cl * user.dwLowDateTime;
    1.31 -        stime = ch * kernel.dwHighDateTime + cl * kernel.dwLowDateTime;
    1.32 -        cutime = 0;
    1.33 -        cstime = 0;
    1.34 -      } else {
    1.35 -        rtime = 0;
    1.36 -        utime = 0;
    1.37 -        stime = 0;
    1.38 -        cutime = 0;
    1.39 -        cstime = 0;
    1.40 -      }
    1.41 +      bits::getWinProcTimes(rtime, utime, stime, cutime, cstime);
    1.42  #endif
    1.43      }
    1.44  
    1.45 @@ -223,7 +202,7 @@
    1.46      double realTime() const {return rtime;}
    1.47    };
    1.48  
    1.49 -  TimeStamp operator*(double b,const TimeStamp &t)
    1.50 +  inline TimeStamp operator*(double b,const TimeStamp &t)
    1.51    {
    1.52      return t*b;
    1.53    }
    1.54 @@ -308,7 +287,7 @@
    1.55      ///
    1.56      Timer(bool run=true) :_running(run) {_reset();}
    1.57  
    1.58 -    ///\name Control the state of the timer
    1.59 +    ///\name Control the State of the Timer
    1.60      ///Basically a Timer can be either running or stopped,
    1.61      ///but it provides a bit finer control on the execution.
    1.62      ///The \ref lemon::Timer "Timer" also counts the number of
    1.63 @@ -416,7 +395,7 @@
    1.64  
    1.65      ///@}
    1.66  
    1.67 -    ///\name Query Functions for the ellapsed time
    1.68 +    ///\name Query Functions for the Ellapsed Time
    1.69  
    1.70      ///@{
    1.71