SPL and foreach Optimized
| From: | (Marcus Börger) | Date: | Sun, 25 May 2003 02:12:01 +0000 |
| Subject: | SPL and foreach Optimized | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-1974@lists.php.net to get a copy of this message | ||
Hi all,
during saturday i've spent some time to optimize SPL. For my testcase it is now 3% faster then
the compareable while code. If OPTIMIZED_ARRAY_CONSTRUCT is defined as in current CVS
then the difference is about 3.5%. Looking at the profiling results on that .5% difference i was
directed to the emalloc change posted earlier. This will bring some more % (hopefully >5%).
SPL uses op1->u.EA.type as an info pointer (called spl_foreach_proxy) to keep track of its
current index and cache the . This can also be used for normal foreach and make the
array copying there obsolete, which also allows some more "code tricks" (as already requested/
bugged on bugs.php.net).
Integrating SPL in the engine would also nearly completly drop the performance loss of the hooks
which is less then 0.5% atm (foreach, array not measured yet).
The optimization used with OPTIMIZED_ARRAY_CONSTRUCT could also be used for normal
foreach.
regards
marcus
--
------------------->>> mailto:mail@marcus-boerger.de
<<<------------------
"We are animals among animals, all children of matter,
save that we are the more disarmed. But since, unlike animals,
we know that we must die, let us prepare for that moment
by enjoying the life that has been given us by chance and for chance."
Umberto Eco, The island of the day before
--------------------->>> http://marcus-boerger.de
<<<---------------------