Boost logo

Boost :

Subject: Re: [boost] [function] function wrapping withnoexceptionsafetyguarantee
From: Daniel Walker (daniel.j.walker_at_[hidden])
Date: 2010-11-02 17:50:52

On Sat, Oct 30, 2010 at 1:25 PM, Domagoj Saric <dsaritz_at_[hidden]> wrote:
> "Daniel Walker" <daniel.j.walker_at_[hidden]> wrote in message
>> Sorry, I must have missed your examples.
> e.g.

Thanks. I added a tarball, signal_benchmark.tar.bz2, with a jamfile
and source code so that anyone who's interested can easily reproduce
this benchmark. The benchmark measures the impact of the static empty
scheme on the time per call of boost::signals2::signal using the code
Domagoj linked to. Thanks to Christophe Prud'homme for the original

Here are the results I got, again, using the build of g++ 4.2 provided
by my manufacturer.

Data (Release):
           | function | function (static empty)
time/call | 3.54e-07s | 3.51e-07s
space/type | 64B | 80B

Data (Debug):
           | function | function (static empty)
time/call | 2.05e-06s | 2.04e-06s
space/type | 64B | 80B

You can see that removing the empty check from boost::function yields
about a 1% improvement in time per call to boost::signal. The
increased space per type overhead is the same as before: 16B.

So, basically, in the use-case measured by this benchmark the time
overhead of boost::function is dwarfed by the combined costs of
boost::signal and the target function, and so using the static empty
scheme does not yield much benefit.

Again, the actual performance will depend on you compiler's
optimization, so some users may receive more benefit than others. This
is why I think we should give users the chance to test the two schemes
in their own applications and choose the one that works best for them.

Daniel Walker

Boost list run by bdawes at, gregod at, cpdaniel at, john at