|
Boost : |
Subject: Re: [boost] [log] Comments
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2010-03-16 11:54:53
On 03/16/2010 02:19 PM, Stewart, Robert wrote:
> That reminds me. Seeing the strings in the library's interface such
> as proposed above make me nervous. In our environment, logging has
> to be very low latency in the calling thread. Checking to see
> whether a severity/component is enabled has to be very fast.
> Strings, such as those appearing in the suggestion above, imply
> higher latency than ideal.
>
> It would be really nice to have a string-to-ID mapping whereby the
> attribute names can be turned into identifiers that can be used
> thereafter for constant time lookup. In the example above, an extern
> std::size_t, say, would hold the ID for "Severity" and another for
> "Channel." Then, the macro would reference those std::size_t's
> rather than the strings, making all uses of that macro much faster.
>
> Adding support for that approach would, most likely, increase the API
> by adding overloads to various functions because the simpler,
> string-based approach may be adequate for many applications.
That looks like a possible optimization, although I'm not sure the final
outcome will be positive. That approach should be well benchmarked
before inclusion.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk