Boost logo

Boost :

Subject: Re: [boost] [smart_ptr] make_shared performance
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2009-01-16 17:29:16


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 16 January 2009 16:46 pm, Emil Dotchevski wrote:
> Benchmarks alone don't mean much without understanding your use case.
> What are you trying to do, for which boost::make_shared's performance
> is inadequate?

Nothing, actually. I was writing some similar code and based it on
boost/make_shared.hpp. I simply became curious if make_shared really was any
faster than using the shared_ptr constructors and new. Normally, I try not
to be an optimization nut, but from n2351, it is clear that performance
optimization is a significant part of the rationale for make_shared existing.

To quote n2351:

"Besides convenience and style, such a function is also exception safe and
considerably faster because it can use a single allocation for the object and
its corresponding control block, eliminating a significant portion of
shared_ptr's construction overhead. This function eliminates one of the major
efficiency complaints about shared_ptr."

So it seems reasonable to expect boost::make_shared to provide some observable
performance benefit.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFJcQo85vihyNWuA4URAp5EAKDTvh71HzwrPRyNI5v4ChC2GNgGNgCg3CDP
ZMWIDAkFVYTae6uDduFEiHo=
=+ohB
-----END PGP SIGNATURE-----


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