
Hi All,
cat progress.cpp
#include
g++ progress.cpp
./a.out 0.00 s
I was expecting a number >= 5.00 s! What am I missing? Thx, Rob.

On Wed, Sep 21, 2011 at 11:47:35AM +0100, Robert Jones wrote:
Hi All, #include
boost::progress_timer t;
0.00 s I was expecting a number >= 5.00 s! What am I missing?
According to the docs for progress_timer, it uses clock(). The man page for clock(3) on my system claims: * The clock() function returns an approximation of processor time used * by the program. That doesn't seem to refer to wall time, so I would recommend you to file a bug against this library. -- Lars Viklund | zao@acc.umu.se

On 21.09.2011 14:05, Lars Viklund wrote:
The man page for clock(3) on my system claims: * The clock() function returns an approximation of processor time used * by the program.
That doesn't seem to refer to wall time
Is this correct according to the C++ standard? I always interpreted the differences between clock()-calls as wall time in conjunction with CLOCKS_PER_SEC. This constant wouldn't make sense otherwise... (?) -- Sebastian Pfützner s.pfuetzner@onlinehome.de ICQ-ID: 39965036

AMDG On 09/21/2011 07:27 AM, Sebastian Pfützner wrote:
On 21.09.2011 14:05, Lars Viklund wrote:
The man page for clock(3) on my system claims: * The clock() function returns an approximation of processor time used * by the program.
That doesn't seem to refer to wall time
Is this correct according to the C++ standard? I always interpreted the differences between clock()-calls as wall time in conjunction with CLOCKS_PER_SEC. This constant wouldn't make sense otherwise... (?)
You'd have to check the C standard. C++ inherits clock from C as is. IIRC, the behavior varies by platform. In Christ, Steven Watanabe

On Wed, Sep 21, 2011 at 04:27:40PM +0200, Sebastian Pfützner wrote:
On 21.09.2011 14:05, Lars Viklund wrote:
The man page for clock(3) on my system claims: * The clock() function returns an approximation of processor time used * by the program.
That doesn't seem to refer to wall time
Is this correct according to the C++ standard? I always interpreted the differences between clock()-calls as wall time in conjunction with CLOCKS_PER_SEC. This constant wouldn't make sense otherwise... (?)
CLOCKS_PER_SEC is just a conversion factor between ticks and seconds of processor time. C99 7.23.2.1/2 says: The clock function determines the processor time used. -- Lars Viklund | zao@acc.umu.se

On Sep 21, 2011, at 8:05 AM, Lars Viklund wrote:
On Wed, Sep 21, 2011 at 11:47:35AM +0100, Robert Jones wrote:
Hi All, #include
boost::progress_timer t; 0.00 s I was expecting a number >= 5.00 s! What am I missing?
According to the docs for progress_timer, it uses clock(). The man page for clock(3) on my system claims: * The clock() function returns an approximation of processor time used * by the program.
That doesn't seem to refer to wall time, so I would recommend you to file a bug against this library.
Yes, this is a well known problem with Boost.Timer. Imagine the fun you can have trying to time the speedup of a multicore program with such a timer. See http://boost.2283326.n4.nabble.com/system-Boost-Timer-replacement-tt3810315.... for Beman's proposed replacement. Vicente Botet is also working on a Stopwatches library based on Chrono for much the same purpose. Cheers, Gordon
participants (5)
-
Gordon Woodhull
-
Lars Viklund
-
Robert Jones
-
Sebastian Pfützner
-
Steven Watanabe