This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Performance Gcc 3.3.1 VS 2.95.1


On Wed, Oct 27, 2004 at 01:37:16PM +0100, Mike Capp wrote:
> > Ouch!  By manipulating the capacity in that way, you force quadratic
> > performance!  The string has to be reallocated every time.  Take out
> > your explicit management of capacity and things will get much faster.
> 
> > If 2.95.1 ran this code faster, I assume it must have ignored your
> >calls to reserve().
> 
> Not necessarily. basic_string::reserve guarantees *at least* the
> requested capacity; it may well allocate more.  If, f'rinstance,
> 2.95.1 rounded reservations up to the next multiple of 64 chars, and
> 3.3.1 rounded up to the next multiple of 16, then 3.3.1 would need to
> reallocate more frequently, explaining the OP's performance
> observations.

Yes, you're right, and my remark about "ignored your calls to reserve()"
is not; your point that differences in the implementation may affect
the result is correct.

I would recommend using reserve() only to reserve a whole lot of space
and thereby do only one reallocation instead of many.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]