Question

<?php   
$t1 = microtime(true);

require("File0.inc"); // size: 7.0 kB
include("File1.inc"); // size: 30.8 kB 
include("File2.php"); // size: 99.0 kB 
require('File3.php'); // size: 1.6 kB 

echo "{includes: ".(microtime(true) - $t1)." seconds}";
?>

This out puts between 0.013 seconds to 0.018 seconds.
This is really inefficient for me, my code (after it) runs in about 0.0002 seconds.
How can I minimize the execution time taken on including the files?

Était-ce utile?

La solution

Including PHP files takes time, there's no way around it.

If the loading time really is such a big issue for you, you may have to just put all the code into one big file. But that's a nightmare when it comes to modularization and code quality, of course, so you should really consider getting a faster server instead of doing this.

Meanwhile, you could try caching your output using memcached or APC to improve loading times.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top