Question pretty much states it all, I am working on a large project where most calls to php include()
between 100 and 150 files. On average the time php takes is between 150 and 300 ms. I'm wondering how much of this is due to including PHP scripts? I've been thinking about running a script that checks most accessed files for particular calls and merge them into one file to speed things up, but for all I know this has zero impact.
I should note that I use APC, I'm not fully aware of what APC does in the background, but I would imagine it might already cache my files somehow so the amount of files doens't really make a big difference?
Would appreciate any input on the subject.
Of course, 300ms isnt much, but if I can bring it down to say, 100 or even 50ms, thats a significant boost.
Edit:
To clarify I am talking about file loading by php include / require.
File loading is a tricky thing. As others have said, the only sure fire way to tell is to do some benchmarks. However, here are some general rules that apply only to PHP loading, not files with fopen:
include
and include_once
(and their require
cousins) are actually quite heavy. Here are some tips to improve their speed:
../foo.php
)_once
functions need to check to make sure that the file wasn't also included via a symbolic link since a symbolic link can produce multiple paths to the same file. This is extremely expensive. (see next point)include
. Make use of auto-loaders to only load classes when they are needed.Overall it is dependent on your hard disk speed. But compared to not loading a file at all or loading it from RAM, file loading is incredible slow.
I hope that helped.