What type of performance hit can I expect if I include a huge PHP array?
For example, lets say I have a 1GB PHP array in “data.php” that looks like
$data = array(
//1GB worth of data
)
If I include that huge “data.php” file on “header.php”, how will it affect the performance of “header.php” when it executes?
Thanks!
Humm… A lot?
data.phpwill be huge, so it will take quite a while to read the file due to disk I/O. Then it has to stay on memory so even if you don’t have memory restrictions it’ll affect performance.Another bottleneck to consider is the
max_execution_timelimit. You’re most probably doing something wrong if you need 1GB of data in memory… Have you considered storing the raw (padded) data, one element per each line and then just request some specific bytes of that file instead?Example (Write):
Example (Read):