[timer] eclapsed return zero
AMDG gmail wrote:
Hello, I have used the timer class in my application. It works ok sometime but i think it dont work correctly. my code is: #include <iostream> #include "boost/timer.hpp" using namespace std; using namespace boost; int main() { int count=0; timer t; for(;count<1000000;++count); cout<
sometime the output is: 0 execute time :0.015s
It looks correct to me. boost::timer is implemented using std::clock() which has a resolution of about 16 ms on msvc. In Christ, Steven Watanabe
________________________________
From: hechaos@gmail.com To: boost-users@lists.boost.org 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!55...
participants (3)
-
gmail
-
Mike Marchywka
-
Steven Watanabe