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

Alfons Adriaensen fons.adriaensen at alcatel.be
Wed Jun 8 09:07:23 UTC 2005


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





More information about the Linux-audio-dev mailing list