Boost logo

Boost :

Subject: Re: [boost] [system] Boost.Timer replacement
From: John Maddock (boost.regex_at_[hidden])
Date: 2011-09-13 13:55:49

> "The best is the enemy of the good."
> Voltaire's famous bon mot applies to a replacement for Boost.Timer.
> I've had a "good", although not "best", replacement ready since circa
> 2006. It has always been set aside waiting for something better. The
> data-time, std::chrono, boost::chrono, boost::stopwatch, and probably
> others, were all candidates.
> I'm tired of waiting.

Me too!!

> documents a useful replacement for
> Boost.Timer. The full library has been in the sandbox for years, but
> current development is on GitHub.
> See
> I'd like to move the header into boost/system/pending or
> boost/system/detail, and the rest into the appropriate libs/system
> subdirectories. The library will be proposed for a full review, or a
> mini-review if enough other Boost libraries start using it. If Endian
> gets accepted, for example, it certainly needs timing benchmarks.

My only comment is that it would be a shame to have duplicate functionality
in the System and Chrono libraries - especially for such a seemingly simple

Only today I through together:

template <class Clock>
struct stopwatch
   typedef typename Clock::duration duration;
      m_start = Clock::now();
   duration elapsed()
      return Clock::now() - m_start;
   void reset()
      m_start = Clock::now();

   typename Clock::time_point m_start;

Is there any reason something like this couldn't be added to Chrono right
away (I'm not so bothered by the reporting ability)?

That said, having a system timer makes sense as well, so go for it I say ;-)


Boost list run by bdawes at, gregod at, cpdaniel at, john at