Re: High bandwidth application tips
| From: | Eugene Lee | Date: | Thu, 06 Nov 2003 07:58:15 +0000 |
| Subject: | Re: High bandwidth application tips | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-168685@lists.php.net to get a copy of this message | ||
On Wed, Nov 05, 2003 at 05:17:29PM -0800, Chris W. Parker wrote:
:
: One thing you can do to make loops faster is the following: (yes I've
: posted this in the past!!)
:
: Unoptimized:
:
: $upperlimit = 100;
:
: for($i = 0;$i < $upperlimit; $++)
: {
: // your stuff
: }
:
: Optimized:
:
: $upperlimit = 100;
: $i = -1;
:
: while(++$i < $upperlimit)
: {
: // your stuff
: }
Still, doing a greater-than or less-than comparison is a bit slow.
You could try this:
$upperlimit = 100;
while ($up-- != 0)
{
// your stuff
}