How expensive is glob'ing a dir and including all the files? [message #179140] |
Fri, 14 September 2012 19:35 |
J. Frank Parnell
Messages: 12 Registered: January 2012
Karma:
|
Junior Member |
|
|
I have my 'funcs' dir, full of about 120 files, totaling ~800KB. A bunch of little utility functions. Here is basically how i include them:
<?php
if ((file_exists($funccache)) AND (@$_GET['recache']!=true)){
include $funccache;//just an array of the files names, see below.
}else{
$incs = glob($funcspath."*.php") ;
$ra = var_export($incs,true);
$put = @file_put_contents($funccache,"<?php \$incs = $ra; ?>");
}
foreach ($incs as $i) {
require $i;
}
?>
So, my question is, am I saving a significant amount of ram/cpu/time by keeping this cache of filenames or should I just glob the dir and include what's in there everytime?
|
|
|