Boost logo

Boost :

From: Dave Harris (brangdon_at_[hidden])
Date: 2005-02-08 14:47:42


In-Reply-To: <001d01c50d76$7f669b20$d9958242_at_heronnest>
cdiggins_at_[hidden] (christopher diggins) wrote (abridged):
> stop() and resume() are not part of the design.
>
> You would write the above code as:
>
> {
> {
> basic_profiler<collecting_policy> p("profile1");
> // some code
> }
> // some other code we do not want to profile
> {
> basic_profiler<collecting_policy> p("profile1");
> // continue profiling
> }
> collecting_policy::generate_report();
> }
> }

It seems to me the tail is wagging the dog here. The RAII class is no
longer a helper but a hinderance that we have to work around. Your
suggestion of adding block-scopes will not work if the first code declares
variables that are used by the second block.

For my own profiling I have a class which is effectively an array of
timers, that can be stopped and started arbitrarily. RAII, when I need it,
is a thin layer on top of that - but usually I don't need it. What I
sometimes need instead is fairly sophisticated interactions between
timers, eg starting one timer implicitly pausing the previous one.

-- Dave Harris, Nottingham, UK


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