Boost logo

Boost :

From: christopher diggins (cdiggins_at_[hidden])
Date: 2005-02-05 16:35:52


Hi,

Sorry in advance for heavy editing of the email.

----- Original Message -----
From: "Preston A. Elder" <prez_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Saturday, February 05, 2005 3:24 AM
Subject: [boost] Re: Profiling Library suggestion

> Problem is, usually a profiler is used to tell you both how many calls are
> made to a function, how long they took cumulatively, and an average.

Good point.

> Alternatively, you could have begin/end sections to profile multiple
> operations:
>
> void MyFunc()
> {
> static ProfileCollection pc;
>
> StartProfileOp(pc, op1);
> op1();
> EndProfileOp(pc, op1);
>
> StartProfileOp(pc, op2);
> op1();
> EndProfileOp(pc, op2);
>
> StartProfileOp(pc, op3);
> op1();
> EndProfileOp(pc, op3);
>
> EndProfile(pc);
> }
>
> This would allow multiple operations to be profiled as one group (the
> second parameter of StartProfileOp and EndProfileOp being just an
> identifier, meaning they'd have to be macros).

How about:

{
  basic_profiler<custom_collecting_policy> p("op1")
  op1();
}
{
  basic_profiler<custom_collecting_policy> p("op2")
  op2();
}
{
  basic_profiler<custom_collecting_policy> p("op3")
  op3();
}

?

And if you like macros, you could always write out:

#define PROFILE(TKN0) { basic_profiler<custom_collecting_policy>
profiler_(#TKN); TKN0(); }

  PROFILE(op1)
  PROFILE(op2)
  PROFILE(op3)

> Also, btw, one of the biggest things would be the ability to DISABLE it
> all, whether by policy or whatever. The last thing I want is to have all
> this timer code active when I'm compiling a production release and not
> trying to tune the code.

Yes definitely, I agree.

> Anyway, if you're looking at a library for this purpose, thats my $.02c :)

Thanks for your contributions.

Christopher Diggins
Object Oriented Template Library (OOTL)
http://www.ootl.org


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