Boost logo

Boost :

From: boost (boost_at_[hidden])
Date: 2006-01-08 14:15:29

"Thorsten Ottosen" <tottosen_at_[hidden]> wrote in message
> David Maisonave wrote:
> >>>I'm not sure what you're referring to here. Can you post an
> >>>example?
> >>
> >>*ptr = *ptr2;
> >
> >
> > Can you please give a more complete example?
> > Which is the smart pointer, here, and exactly what type of pointers?
> let's assume non of the types involved are abstact.
> Anyway, we have been here before and are starting to move in circles.

Even if we assume none of the types are abstract, I still don't understand
what's suppose to happen in above code.
What type is what in above example?

By the way, I figured out why some of the results were so poor for copy_ptr
and cow_ptr.
Some of it had to do with assert logic, and some of it had to do with the
boost pointer performing slicing.
I had a derived derived class that I left out the clone function
intentionally for a different test, and I mistakenly used it for the
performance test.

The cow_ptr still suffers in performance when populating the container
compared to boost pointer. It's a approximately a two to one ratio.
But the cow_ptr also still out performance the boost container by abut 4 to
1 when doing a copy of the container.

I think the call to new in the cow_ptr constructor is what's making the
difference when populating the container.

The copy_ptr has similar results to the boost pointer container, except for
the copy container test, in which it seems to out perform the boost pointer
by about %20.
You can download the new code via following link:

Here are the new results:
Test performance for interating through a container of pointers via [].
vector<copy_ptr<Shape> > 1.80 s
boost::ptr_vector<Shape> 1.81 s
vector<cow_ptr<Shape> > 2.06 s

Test performance for interating through a container of pointers via
vector<copy_ptr<Shape> > 1.80 s
boost::ptr_vector<Shape> 1.77 s
vector<cow_ptr<Shape> > 1.94 s
vector<copy_ptr<Shape> > 1.78 s
boost::ptr_vector<Shape> 1.78 s
vector<cow_ptr<Shape> > 1.95 s

Test performance for populating container of pointers via factory method.
vector<copy_ptr<Shape> > 2.13 s
boost::ptr_vector<Shape> 1.86 s
vector<cow_ptr<Shape> > 3.63 s
vector<copy_ptr<Shape> > 2.13 s
boost::ptr_vector<Shape> 1.88 s
vector<cow_ptr<Shape> > 3.66 s

Test performance for initializing and copying container of pointers.
vector<copy_ptr<Shape> > 28.91 s
boost::ptr_vector<Shape> 36.11 s
vector<cow_ptr<Shape> > 9.34 s
vector<copy_ptr<Shape> > 28.38 s
boost::ptr_vector<Shape> 35.70 s
vector<cow_ptr<Shape> > 9.41 s

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