Re: PHP Performance and System Load

From: Date: Fri, 20 Jul 2007 09:16:33 +0000
Subject: Re: PHP Performance and System Load
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-259212@lists.php.net to get a copy of this message
Sancar Saran wrote: > Another simple performance tip. > > Most of for examples of php look like this > for($x=0;$x<sizeof($arrSometing);$x++) > > This is bad. In every cycle you call sizeof > > this was good > $intSize = sizeof($arrSometing); > for($x=0;$x<$intSize;$x++) > > if u use. > for($x=0;$x<$intSiz;++$x). You may gain another %10 > > to determine costs of your functions use xdebug and kcachegrind. I've always used pre-increment in loops like you suggest as it was an ingrained part of my C/C++ learning from a performance perspective. I wasn't sure if the same was true in PHP but you seem to suggest it is, so I feel justified now :) Col

« previous php.general (#259212) next »