Boost logo

Boost :

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


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

I've been doing a little benchmarking (trivial benchmark program attached) of
boost::make_shared performance. With svn trunk, I don't see much improvement
from using make_shared, in fact for large objects it is much slower. I would
guess this is due to the increased overhead of copying sp_ms_deleter for
large types. I wonder if anyone has any ideas for improving the situation?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFJcP7d5vihyNWuA4URApVPAJ9EfS6MtkNHTUgb/gOTD/nRngPiUQCeL6K0
MtkmtRAmzKlN1m0eXO9t5k0=
=LpQ1
-----END PGP SIGNATURE-----

--Boundary-00=_d7PcJY6AW+vf8hK
Content-Type: text/x-c++src; charset="utf-8"; name="make_shared_benchmark.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
        filename="make_shared_benchmark.cpp"

#include <boost/make_shared.hpp>
#include <boost/shared_ptr.hpp>

struct X
{
  int x[1000];
};

int main()
{
  static const unsigned num_iterations = 10000000;
  for(unsigned i = 0; i < num_iterations; ++i)
  {
// boost::shared_ptr<X> p(new X);
     boost::shared_ptr<X> p = boost::make_shared<X>();
  }
}

--Boundary-00=_d7PcJY6AW+vf8hK--


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