RE: [PHP] High bandwidth application tips
| From: | Wouter van Vliet | Date: | Thu, 06 Nov 2003 01:37:02 +0000 |
| Subject: | RE: [PHP] High bandwidth application tips | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-168646@lists.php.net to get a copy of this message | ||
Whow, is that way of a loop really faster? I mean .. It looks as if the
accept same thing happens
- $upperlimit is set
- $i counter is set
- for every loop $i is set one higher
- Also for every loop the expression ($i<$upperlimit) is evaluated.
Any idea on why it's faster?
-----Original Message-----
From: Chris W. Parker [mailto:cparker@swatgear.com]
Sent: Thursday 06 November 2003 02:17
To: Php-General (E-mail)
Subject: RE: [PHP] High bandwidth application tips
Wouter van Vliet <mailto:wouter@springt.nl>
on Wednesday, November 05, 2003 5:06 PM said:
> * Unset when not used anymore
I don't do this enough.
>> Me neither, to be honest ;)
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
}
Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php