Re: [Boost-bugs] [Boost C++ Libraries] #1962: Doesn't measure wall clock time

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #1962: Doesn't measure wall clock time
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-10-29 09:53:23


#1962: Doesn't measure wall clock time
---------------------------+------------------------------------------------
  Reporter: dave | Owner: bemandawes
      Type: Bugs | Status: new
 Milestone: Boost 1.36.0 | Component: timer
   Version: Boost 1.35.0 | Severity: Problem
Resolution: | Keywords:
---------------------------+------------------------------------------------

Comment(by r.jordans_at_[hidden]):

 The problem here is a generic one. The timer class uses clock() to measure
 time and this function is defined differently for Windows and Unix
 systems. On Windows it is defined as the wall clock time while on most
 Unix derivatives the total CPU time of the process is used.

 A simple example: (test_clock.c)
 #include <time.h>
 #include <stdio.h>
 #include <unistd.h>

 int main(int argc, char **argv)
 {
         time_t start = clock();

         printf("Sleeping 1 second... ");
         fflush(stdout);

         sleep(1);

         printf("done\n");
         printf("Time elapsed: %f\n",
 (clock()-start)/((float)CLOCKS_PER_SEC) );

         return 0;
 }

 Will result in the following output:
 roel_at_localhost:~ $ ./test_clock
 Sleeping 1 second... done
 Time elapsed: 0.000000

 Which is a completely different concept of time when compared to the
 result on Windows.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/1962#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:59 UTC