Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!yojimbo.hack!news.tokachu.com!.POSTED!not-for-mail From: Salvatore Newsgroups: comp.lang.php Subject: Re: How expensive is glob'ing a dir and including all the files? Date: Fri, 14 Sep 2012 19:44:37 +0000 (UTC) Organization: Yojimbo NNTP server Lines: 29 Message-ID: References: <38015b6a-5ef2-4f92-9aa2-6eea01c7097a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: yojimbo.hack "kq(Iga%czn" X-Complaints-To: usenet(at)tokachu(dot)com User-Agent: slrn/0.9.9p1 (FreeBSD) X-Watermark: "Q( 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: > 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,""); > } > 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++