Boost logo

Boost :

Subject: Re: [boost] [timer] Boost Timer Library Version 2
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2011-09-27 17:01:10


Le 27/09/11 15:54, Beman Dawes a écrit :
> Version 2 of Boost.Timer is about ready to move to trunk. The original
> version 1 timers are deprecated, but not changed in any way.
>
> Besides deciding to keep the version 2 timers in Boost.Timer, many
> suggestions and corrections from the "Boost.Timer replacement" thread
> have been applied. See
> http://lists.boost.org/Archives/boost/2011/09/185820.php
>
> The docs can be viewed at http://beman.github.com/timer/
>
> The code is available at https://github.com/Beman/timer
>
> Thanks to all who posted comments, corrections, and suggestions in
> response to the original posting.
>
> Special thanks to Rob Stewart - many of his suggestions have been
> incorporated - and to Vicente Botet for his work on Boost.Chrono which
> now is used to implement much higher resolution for wall-clock time.
>
> While additional comments are always welcome, unless someone comes up
> with a showstopper I'm planning to move Version 2 to trunk and get on
> with other projects.
>
Hi Beman,

glad to see that you could make use of Boost.Chrono.

I have some remark about the documentation.

* The example

using boost::timer::cpu_timer;
...
nanosecond_type last_checkpoint = 0;
cpu_timer checkpoint_timer; // start the timer

while (more_transactions)
{
   process_a_transaction();
   if (checkpoint_timer.elapsed().user - last_checkpoint> 20*1000000000)
   {
     create_checkpoint();
     last_checkpoint = checkpoint_timer.elapsed().user;
   }
}

seems to not really show the a well use of elapsed. For example the same
behavior can be done with Boost.Chrono as follows

using boost::chrono;
...
process_user_cpu_clock::time_point last_checkpoint = process_user_cpu_clock::now();

while (more_transactions)
{
   process_a_transaction();
   if (process_user_cpu_clock::now() - last_checkpoint> seconds(20))
   {
     create_checkpoint();
     last_checkpoint = process_user_cpu_clock::now();
   }
}

Note that the comparison is done using duration units.

I guess that you should include a more specific example that show the
advantage of using a timer.

* By the way the user, wall and system fields are not chrono::duration?
or why you don't use the chrono::process_cpu_clock that provides wall,
user and system clocks at once?

* Why does stop returns cpu-times? Why by reference? Why elapsed is not
returned by reference?

cpu_times elapsed() const noexcept;

const cpu_times& stop() noexcept;

* I would associate the operations pairwise start/stop and
suspend/resume. I guess it would be easier to explain the semantics.

Best,
Vicente


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