Re: [linux-audio-dev] [ot] [rant] gcc, you let me down one time too many

From: Alfons Adriaensen <fons.adriaensen@email-addr-hidden>
Date: Wed Jun 08 2005 - 12:07:23 EEST

On Wed, Jun 08, 2005 at 09:50:42AM +0100, Simon Jenkins wrote:

> Suppose I sum a vector of 5 million integers and it takes 6 seconds. And
> assume - (generously![1]) - that I switch to using an array and now it
> only takes 1 second. Hmmm... a 6 * speedup! So I look to see where else
> my code could benefit from this super performance boost.
>
> Aha! Here's a vector of 5,000 oscillator structures, and it takes 5
> seconds to initialise them all. Switch to using an array and... erm...
> now it only takes 4.995 seconds to initialise them all.

When all you need is the random access of a C array (or maybe even less,
just sequential acces), and this is something you should know _before
writing one letter of code_, why waste your time by writing it first using
a vector and changing it afterwards ? Just write it using an array _from
the start_. It takes no more time or effort than using a vector.

-- 
FA
Received on Wed Jun 8 16:15:06 2005

This archive was generated by hypermail 2.1.8 : Wed Jun 08 2005 - 16:15:06 EEST