Boost logo

Boost Users :

Subject: Re: [Boost-users] [timer] eclapsed return zero
From: Mike Marchywka (marchywka_at_[hidden])
Date: 2008-09-05 14:43:37


________________________________
> From: hechaos_at_[hidden]
> To: boost-users_at_[hidden]
> Date: Fri, 5 Sep 2008 19:15:07 +0800
> Subject: [Boost-users] [timer] eclapsed return zero
>
> Hello, I have used the timer class in my application. It works ok sometime but i think it dont work correctly.

I'm not sure how timer is supposed to work but a few general comments.
Other than the obvious, "your mileage may vary" ( it really could be that fast),
I'm not even sure the compiler has to execute the loop if you turn on optimizations
and don't mark count as volatile as the intermediate results are unobservable.
Since no one looks at the end, it really never even needs to push count.

I think that is legal anyway, opposing viewpoints welcome :)

> my code is:
> #include
> #include "boost/timer.hpp"
> using namespace std;
> using namespace boost;
> int main()
> {
> int count=0;
> timer t;
> for(;count cout< return 0;
> }
> and the output:
> 0.015
> execute time :0.062s
>
> sometime the output is:
> 0
> execute time :0.015s
>
> regards
> hechao

_________________________________________________________________
Get more out of the Web. Learn 10 hidden secrets of Windows Live.
http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008


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