note 37318 deleted from function.count by sp
| From: | sp@php.net | Date: | Wed, 12 Nov 2003 03:18:20 +0000 |
| Subject: | note 37318 deleted from function.count by sp | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-60274@lists.php.net to get a copy of this message | ||
Note Submitter: andreas@sassermann.de
----
One note about speed:
I just had an impressing speedup with a very tiny change.
Having an array with 1500 Elements, the following code took about 15 seconds:
<?php
for($intItem = 0; $intItem < count($aItemData); $intItem++)
{
// ... do something ...
}
?>
By just assigning the number of items to a variable and comparing against this, reduced the total
execution time to 0.9 seconds (yes TO, not BY)
<?php
$intCount = count($aItemData);
for($intItem = 0; $intItem < $intCount; $intItem++)
{
// ... do still the same ...
}
?>