Thursday, March 23, 2006, 03:44:11, Teg wrote:

> Hello Jay,

> Best way I've found to get great performance out of strings and
> vectors is to re-use the strings and vectors. String creation speed is
> completely dependent on allocation speed so, by re-using the strings,
> you only grow the ones that aren't already big enough to hold the new
> string data so, eventually they don't grow at all.

> At least with STLPort STL which I use, a "clear" doesn't de-allocate
> the space then re-use simply fills in the already allocated space.

I can second that in principle. In my case it was still the first step
only (albeit with very notable effect). But in the end it was not as
fast as a) not using vectors at all and b) (even more impact), not to
convert doubles, int's etc. into text. IMO, general advice is, to avoid
any not required copies (even if you have reference-counted copy ctors
or whatever optimization on user class level) and unnecessary
conversions. Also setting up vectors/matrices and presetting the size
(and increasing later on) requires time and memory, if you have the data
in another structure anyway. The system here was mainly WinXP Visual
Studio 2003 with his native STL and a recent Redhat Linux on Opterons.

Micha  
-- 

Reply via email to