On Mon, Aug 27, 2012 at 6:54 PM, Matijn Woudt <tijn...@gmail.com> wrote:
> On Mon, Aug 27, 2012 at 10:56 PM, Haluk Karamete
> <halukkaram...@gmail.com> wrote:
>> Now, the question is... should you use a global include that points to
>> this library - across the board - so that ALL the pages ( including
>> the 90% that do not need the library ) will get it, or should you
>> selectively add that include reference only on the pages you need?
> Since searching for files is one of the most expensive (in time)
> operations, you're probably best off with only a single PHP file.

Maybe I misinterpreted the question, but I don't think I agree.

If you have a 50K PHP file that's only needed in only 10% of the
pages, then, when solely considering performance, that file should
only be included on the 10% of the pages that actually use the file.
Now, there are reasons where you might want to include the file
globally (maintenance purposes, etc.) Loading the 50K of PHP code
requires building up all of the associated infrastructure (zvals,
etc.) for the user code (even if APC is used, the cached opcode/PHP
bytecode still has to be parsed and built up for the user-defined
classes and functions per request, even if they're unused), is
certainly going to perform more slowly than selectively including the
library on only the pages that need the library.


Nephtali:  A simple, flexible, fast, and security-focused PHP framework

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to