Boost logo

Boost :

From: Silex (silex0r_at_[hidden])
Date: 2006-05-21 06:56:55


Hello,

As I didn't receive the answers I was looking for, here is my last proposal.

My imlpementation does the templating of the timer class as suggested.
By using boost::posix_time::microsec_clock as the template parameter,
we are able to do microsec timing. This works fine, at least in the
environnements I tested it (windows 2000 and gentoo).

I added two typedefs:

    typedef boost::timer<boost::posix_time::second_clock> second_timer;
    typedef boost::timer<boost::posix_time::microsec_clock> microsec_timer;

Now one can simply use boost::microsec_timer and time his code at
microsecond level.

Because of the long discussion about QueryPerformanceCounter that
didn't came to a real conclusion, I decided to implement two
additionnal timers:

- boost::qpc_timer, which use QueryPerformanceCounter() for its resolution.
- boost::tgt_timer, which use timeGetTime() for its resolution.

As using those timers would make no sense on another platform than
windows, those are not defined by default. One must #define
BOOST_QPC_TIMER to get boost::qpc_timer and must #define
BOOST_TGT_TIMER to get boost::tgt_timer.

Trying to do those defines on another platform than windows results in
an #error.

Please tell me what do you think of the code (review ?) and tell me if
this is ok for boost.

To test it simply put timer_new.hpp into the boost folder and compile
main.cpp, uncommenting the macros at top to test the second/qpc/tgt
timers if wanted.

The goal is that timer_new.hpp is then renamed to timer.hpp and
replaces the current header.

Thank you
Philippe




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