FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » How expensive is glob'ing a dir and including all the files?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: How expensive is glob'ing a dir and including all the files? [message #179142 is a reply to message #179140] Fri, 14 September 2012 19:44 Go to previous messageGo to previous message
Salvatore is currently offline  Salvatore
Messages: 38
Registered: September 2012
Karma:
Member
On 2012-09-14, J. Frank Parnell <juglesh(at)gmail(dot)com> 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:
> <?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?

You're only making your script unnecessarily complicated. Just use the
include() function to only include the functions you need.

If you have performance issues -- which you shouldn't -- consider
installing a PHP accelerator.

--
Blah blah bleh...
GCS/CM d(-)@>-- s+:- !a C++$ UBL++++$ L+$ W+++$ w M++ Y++ b++
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: php and PDO Error HTTP 500
Next Topic: PHP Update
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 13:59:43 GMT 2024

Total time taken to generate the page: 0.04998 seconds