array iteration vs. ArrayIterator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



all,

as ive been researching SPL lately ive read several times that spl will
store only the current element of the underlying collection in memory
during iteration.  articles that mention this will say that using these
iterators should afford savings when traversing large collections.  well
having found nothing empirical i decided to run some tests myself.
and for the hell of it, i also decided to throw the array-by-reference
construct in there (thats the name im giving to the syntax which lets
you alter the array youre iterating over from within the array).  mainly
because ive heard people say it will save memory.  however, based
upon some things ive read, ive been skeptical of that info.
so here is a quick little report i whipped up, which has the script i used
for the test, and the results in a graphical format so you can get a quick
feel for them.
http://nathan.moxune.com/arrayVsArrayIteratorReport.php

at this point i must retract some of the statements i made during the
conversation about ruby yesterday.  it turns out, spl iteration is not
twice as fast as standard array iteration, in fact it quite a bit slower!
also, it takes up more memory, and lastly, whoever said that using the
array-by-reference syntax saves memory is dead wrong ;)

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux