Re: PHP Script Speed
| From: | Richard Lynch | Date: | Tue, 09 Jul 2002 09:50:18 +0000 |
| Subject: | Re: PHP Script Speed | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-106319@lists.php.net to get a copy of this message | ||
>but I am wondering if it is at the cost of a slower page loading. The reason
>I think this is whenever I would like to display a variable I have to put in
>a script tag like <?PHP print $S_Current; ?>. I might have as many as 20 of
>these on a page. Every time doesn't PHP have to start again and parse out
>this information causing it to be really slow?
PHP is already started, and going, and reading your HTML.
It only has to notice when you have <?php and start paying a little more
attention instead of just spewing out the HTML it encounters.
The context change from HTML mode to PHP mode is a negligible, practically
un-measurable performance hit.
I switch back/forth way more than 20 times in most scripts.
Rule of Thumb:
90% of your script's time is being spent in 10% of the code.
If it's "too slow" figure out where that 90% is, and optimize that.
Actually, it's a bit more complicated than that in the web...
That 90% might all be in MySQL, or in the network congestion, or in your
messed-up reverse DNS lookup, or...
But, still, if you've narrowed the speed problem down to PHP itself, then
start figuring out where it's spending all its time *before* you change a
line of code.
If it's not "too slow" don't even worry about performance, unless you are
actually working on a site that is likely to balloon into millions of users
or whatever.
Even then -- only testing *YOUR* site, and *YOUR* set up will find the 90%
reliably.
--
Like Music? http://l-i-e.com/artists.htm