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.
Yes it will slowdown if you are including the script from other servers.
Disabling or setting the page file size too small can reduce system performance and cause instability and crashes in Windows.
If your server supports PHP, then you do not need to do anything. Just create your . php files, put them in your web directory and the server will automatically parse them for you. There is no need to compile anything nor do you need to install any extra tools.
So what exactly is a PHP file? Generally speaking, a PHP file is a plain-text file which contains code written in the PHP programming language. Since PHP is a server-side (back-end) scripting language, the code written in the PHP file is executed on the server.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With