Boost logo

Boost :

Subject: Re: [boost] [system] Boost.Timer replacement
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2011-09-13 16:20:39


Le 13/09/11 19:55, John Maddock a écrit :
>> "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!!
>
>> http://beman.github.com/timer/ documents a useful replacement for
>> Boost.Timer. The full library has been in the sandbox for years, but
>> current development is on GitHub.
>>
>> See https://github.com/Beman/timer
>>
>> 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 utility.
>
> Only today I through together:
>
> template <class Clock>
> struct stopwatch
> {
> typedef typename Clock::duration duration;
> stopwatch()
> {
> m_start = Clock::now();
> }
> duration elapsed()
> {
> return Clock::now() - m_start;
> }
> void reset()
> {
> m_start = Clock::now();
> }
>
> private:
> 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)?
>
>
I could add a basic stopwatch quite soon, as there is no reporting.

Best,
Vicente


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