Boost logo

Boost :

From: christopher diggins (cdiggins_at_[hidden])
Date: 2005-02-10 17:25:44


----- Original Message -----
From: "Brian Braatz" <brianb_at_[hidden]>
> [Brian Braatz]
> Hahahahaha
>
> " Macros were avoided because everyone knows macros are evil, unless we
> are the ones writing them."
>
> I LOVE THIS LINE. Please keep it in :)

Thanks :)

> On a serious note though, with your lib done the way it is , if someone
> WANTS macros, there is nothing preventing them from having them.
>
> I for example- MIGHT take your library and stuff __FILE__ __LINE__ into
> the id. For this I would use a macro. This is also why I made the
> request for the char*name type to be a template param. I may want to
> plop in my own struct that has the __FILE__ and __LINE__ in it.

The current implementation uses a map<string, pair<int, double> > for
gathering of stats. This makes it easy to access data by profile name and to
accumulate data for a named profile. Of course this could be rewritten, but
my goal is to do as little work as possible. ;)

What if instead you wrote:

#define PROFILE(TKN) BOOST_PROFILE(#TKN##__FILE__##__LINE__)

Or better yet:

#ifndef BOOST_PROFILING_OFF
  map<string, pair<int, string> > my_map;
#endif

#ifndef BOOST_PROFILING_OFF
  #define PROFILE(TKN) mymap[#TKN] = pair<int,string>(__LINE__, __FILE__);
BOOST_PROFILE(#TKN);
#else
  #define PROFILE(TKN) /* */
#endif

Would these be acceptable alternatives?

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