Boost logo

Boost Users :

Subject: Re: [Boost-users] A problem on using boost timer (different time intervals were showed). Can any one with kindness help me?
From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2009-09-24 03:38:07


2009/9/24 fmingu <fmingu_at_[hidden]>

> I am using boost timer in C++ builder 2009 to test the time used in my
> program.there are the lines:
> ....................
> boost::timer t;
> double timeresult;
> ...................
> t.restart();
> ........... //my program main body
> timeresult=t.elapsed();
> ShowMessage( " the time consumed by my program is
> "+FloatToStr(timeresult));
> .........................
> the program was compiled and linked and worked well.
> But I find a problem:
> every time the message showed is not the same time interval,
> sometimes it is 0.015 and sometimes it is 0.016 and sometimes it is 0.
> I do not know how it was happened.
> Does it happen due to the multi-process and multi-thread mode by windows?
> I do not know how to solve it. My program is quite strict on the time
> consumed by the computer.
> Can any one with kindness help me?
>

You didn't specify which operating system you are using, but I if it's not a
real time OS, there is no guarantee that the same code will take the same
time to execute on each run. For small programs (in terms of run time) the
difference can be huge (easily an order of magnitude).

Roman Perepelitsa.



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