Re: How expensive is glob'ing a dir and including all the files? [message #179144 is a reply to message #179143] |
Fri, 14 September 2012 23:24 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 9/14/2012 6:24 PM, J. Frank Parnell wrote:
> On Friday, September 14, 2012 12:41:35 PM UTC-7, Eli the Bearded wrote:
>> In comp.lang.php, J. Frank Parnell <> wrote:
>>
>>> 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:
>>
>> ...
>>
>>> 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?
>>
>>
>> The glob for a directory with 120 files will be nothing compared to
>> the time it takes php to include() 800KB worth of stuff. You might
>> want to consider only including what you really need. That will be
>> the bigger win.
>> ---
>> glob on a very big directory (multiple thousands of files) is different
>
> When I do properties locally, on Win, it says size: 408KB, size on disc: 720KB. Compared to the wordpress 'includes' dir at 5Megs, doesnt seem like much, although i'm not sure if wp includes that whole dir, always. Would it be more efficient to concatenate my include files?
>
As others have said - include only what you need. The time consuming
part is parsing the PHP code, not reading one or more files.
Concatenating will still require PHP to parse the code.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|