Hi Andrew,

I suggest you read Scott Meyer's book - Effective STL - Item #18: "Avoid using 
vector<bool>"

I was able to find the book online at: 
http://www.uml.org.cn/c++/pdf/EffectiveSTL.pdf

Cheers,

    Erik

On 04-09-2010, at 00:27, Andrew Cunningham wrote:

> Hi,
> I am looking at a performance slow-down  introduced after using some 
> osg::Switch groups.
> 
> I did some performance benchmarking on std::vector<bool> and I found 
> push_backs are 10x slower than std::vector<int>, and more importantly, the 
> simple [] operator is about 20x slower(*). I am not sure it is the smoking 
> gun yet, as I will need to back-track a lot of code, but it looks possible.
> 
> This is because std::vector<bool> is specialized in the STL to be a memory 
> efficient packed vector.
> 
> I am not so sure that the memory (<bool> vs say <unsigned char> ) saved is 
> really worth  the performance hit in the case of osg::Switch
> 
> (* Win32, _SECURE_SCL=0, Studio 2008)
> 
> Andrew
> 
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=31323#31323
> 
> 
> 
> 
> 
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to