Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2006-06-25 20:07:48


Silex wrote:
> Hello
>
> Here attached is the latest version of the boost::timer modification.
>
> About doing the documentation I must say that QuickBook & BoostBook
> confused me. I understand QuickBook generates BoostBook's
> documentation but how to use it ?
>
> At the moment I'm only doing the documentation in a plain text file
> waiting for your answers...
> I *think* I understood that I'm supposed to write a .qbk file, but how
> to then make Spirit generate the xml for BoostBook is beyond me, I'm
> not used to Spirit yet.

Hi Philippe -

Sorry I haven't got a chance to look at this till now. First, it might be
nice if you could upload a version to the vault so other people can try it out.

http://boost-consulting.com/vault/index.php?&direction=0&order=&directory=date_time

Now a couple questions on the code. What is the

     time_duration_type elapsed() const
     {
         if(m_start.QuadPart)
         {
             LARGE_INTEGER current;
             if(!QueryPerformanceCounter(&current))
                 throw std::runtime_error("qpc: QueryPerformanceCounter()
failed");
             boost::uint64_t milliseconds = (current.QuadPart -
m_start.QuadPart) / m_frequency.QuadPart;
             boost::uint32_t seconds = milliseconds / 1000;
             boost::uint32_t minutes = seconds / 60;
             boost::uint32_t hours = minutes / 60;
             milliseconds = milliseconds % 1000;
             m_elapsed += time_duration_type(hours, minutes, seconds,
milliseconds);
             m_start = current;
         }
         return m_elapsed;
     }

I think this code is both inefficient and likely non-portable. As I
understand it, QueryPerformanceCounter has a hardware defined resolution that
can be queried by calling QueryPerformanceFrequency. QPF provides the counts
per second. You should be able to use this to more simply construct the
time_duration. So, for example, if QPF returned 1000 you could simply say

             m_elapsed += boost::posix_time::milliseconds(current-previous);

I'm guessing nanoseconds might be the best duration type to use in the
calculation.

Thx for your effort in this area.

Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk