RE: [PHP] optimal code
| From: | Richard Heyes | Date: | Thu, 05 Jul 2001 13:03:37 +0000 |
| Subject: | RE: [PHP] optimal code | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-56305@lists.php.net to get a copy of this message | ||
> But, my friend, if you include that file, PHP _still_ has
> to parse it. You just didn't benchmark. No matter what
Actually, I did do benchmarks, you simply didn't understand correctly.
Not all of the functions are used on every page. So if I were to include
all the functions in one file, roughly 30 functions worth of code would
need to be unnecessarily parsed, which obviously causes unecessary
slowdown. This is similar to the original version 2:
/** Version 2 **/
<?
if($condition) {
include 'file_with_some _big_code.php';
} else {
include 'file_with_other_big_code.php';
}
?>
This code will run one set of code. Having the other set of "big_code"
parsed is pointless. FWIW, it's this cutting out of parsing code that
makes the Zend Cache produce such high speed increases.
--
Richard Heyes