Boost logo

Boost Users :

From: Ruediger Berlich (ruediger.berlich_at_[hidden])
Date: 2007-07-05 06:22:45


Hi again,

apologies - probably my last posting was a stupid one. I had
interpreted "The timer library supplies a timer class for measuring elapsed
time" in such a way that the library can be used to measure a given amount
of real time. However, the library internally uses the clock() call,
which "returns an approximation of processor time used by the program". As
I have just used usleep calls to simulate activity, the timer always
returned 0. I will use the date_time library now instead, as my application
spends a lot of time being idle.

Thanks and Best Regards,
Ruediger

Ruediger Berlich wrote:

> Hi there,
> the following program
>
> /****************************************************/
>
> #include <iostream>
> #include <boost/timer.hpp>
>
> using namespace std;
>
> boost::timer t;
>
> main()
> {
> t.restart();
> for(int i=0; i<5; i++){
> usleep(500000);
> cout << t.elapsed() << endl
> << t.elapsed_min() << endl
> << t.elapsed_max() << endl;
> }
> }
>
> /****************************************************/
>
> gives five times the following output, in 0.5 s intervals:
>
> 0
> 1e-06
> 9.22337e+12
>
> I have tried the timer_test.cpp application (from
> http://www.boost.org/libs/timer/index.html). Most of it seems to be
> working, but the first messages also say:
>
> timer::elapased_min() reports 1e-06 seconds
> timer::elapased_max() reports 9.22337e+12 seconds,
> which is 2.56205e+09 hours
>
> After this the output seems to be fine.
>
>
> So something clearly is wrong. Any ideas ?
>
> This is on an OpenSuSE 10.2 system with a Boost 1.34.0 (with added ASIO
> support, 0.38rc3). g++ is 4.1.2 .
>
> Thanks and Best Regards,
> Ruediger


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net