Boost logo

Boost :

From: Thorsten Ottosen (tottosen_at_[hidden])
Date: 2006-01-04 11:08:15


axter wrote:
> This is a continuation on a thread discussion advocating replacing the boost
> pointer containers with cow_ptr as the default pointer containers.
> http://code.axter.com/boost_ptr_containers/maintest.cpp
> http://code.axter.com/shape_test.h
> http://code.axter.com/cow_ptr.h
> http://code.axter.com/copy_ptr.h
> The above code was used to make the comparison, and the following is the
> result using VC++ 7.1 on XP with a 2G processor.
> Test performance for interating through a container of pointers via [].

>
> I like to see if any one can test this out on other platforms and/or
> compilers to see if the results differ.

On visual c++ 7.1 I get the following:
  cl /EHsc /Ox /Og /O2 /DNDEBUG=1 maintest.cpp /I../../boost/boost/

$ ./maintest.exe
Test performance for interating through a container of pointers via [].

vector<copy_ptr<Shape> > 1.28 s

boost::ptr_vector<Shape> 1.27 s

vector<cow_ptr<Shape> > 1.41 s

>>>>>>>>>>>>>>>>
It appears that you ran the test with BOOST_ASSERT enabled.

Test performance for interating through a container of pointers via
iterators.

vector<copy_ptr<Shape> > 1.28 s

boost::ptr_vector<Shape> 1.22 s

vector<cow_ptr<Shape> > 1.34 s
>>>>>>>>>>>>>>>>>

I precalculated the end() iterator, as one would normally do. This seems
to be slightly slower in ptr_vector, which makes sense given the extra
wrapper layer.

Test performance for initializing and copying container of pointers.

vector<copy_ptr<Shape> > 0.42 s

boost::ptr_vector<Shape> 0.42 s

vector<cow_ptr<Shape> > 0.09 s
>>>>>>>>>>>>>>>>>>

cow_ptr seems to win here. I can't figure out why cow_ptr is so much
faster. ptr_vector uses cloning, of course, whereas cow_ptr does
something else.

Test performance for populating container of pointers via factory method.

vector<copy_ptr<Shape> > 0.30 s

boost::ptr_vector<Shape> 0.08 s

vector<cow_ptr<Shape> > 0.11 s

Tryk på en vilkårlig tast for at fortsætte . . .

-Thorsten


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