This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Performance Gcc 3.3.1 VS 2.95.1
Hi Joe,
Thanks for your reply.
hmm... That program's purpose is to test performance. Our project got
slower after upgrade. So I wrote some programs to figure out what cause
that problem. Thus I reallocate the str each time. I got confused by "
2.95.1 may have ignored reserve()". 2.95.1. got correct result though.
-Richard
On Tue, 26 Oct 2004, Joe Buck wrote:
> On Tue, Oct 26, 2004 at 05:46:26PM -0500, Yingqi(Richard) XIAO wrote:
> > I upgraded one of my gcc from 2.95.1 to gcc 3.3.1 month ago. But now I
> > found the performance of compiled code is worse than before. It is worse
> > even with optimization than compiled with 2.95.1 without optimization. For
> > example,
> >
> > for (i = 0; i < n; i++)
> > {
> > capacity += 6;
> > str.reserve(capacity);
> > str += "hello\n";
> > }
>
> > This program will make significant different performance. Could you give
> > me some explaination? Thanks.
>
> 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.
>
> (I use a question related to this example as an interview question, to
> see if the candidate understands performance issues).
>
> If 2.95.1 ran this code faster, I assume it must have ignored your
> calls to reserve().
>