Perl: the Markov chain saw | |
PerlMonks |
Re: Re: It's bad manners to slurpby BrowserUk (Patriarch) |
on May 02, 2004 at 17:31 UTC ( [id://349837]=note: print w/replies, xml ) | Need Help?? |
The for version creates a (potentially large) list, whereas the while version does not. The cost of allocating the list is offset against repeated calls to each, with the result that for small lists, for iterates faster, but on larger lists the while version wins out. A quick test show that the break even point on my system is around 8000 elements. YMMV
Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham"Think for yourself!" - Abigail
In Section
Meditations
|
|