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: 0
|
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?
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179141 is a reply to message #179140] |
Fri, 14 September 2012 19:41 |
Eli the Bearded
Messages: 22 Registered: April 2011
Karma: 0
|
Junior Member |
|
|
In comp.lang.php, 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:
....
> 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.
Elijah
------
glob on a very big directory (multiple thousands of files) is different
|
|
|
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 |
Salvatore
Messages: 38 Registered: September 2012
Karma: 0
|
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++
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179143 is a reply to message #179141] |
Fri, 14 September 2012 22:24 |
J. Frank Parnell
Messages: 12 Registered: January 2012
Karma: 0
|
Junior Member |
|
|
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?
|
|
|
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: 0
|
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
==================
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179145 is a reply to message #179144] |
Fri, 14 September 2012 23:43 |
Michael Fesser
Messages: 215 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
.oO(Jerry Stuckle)
> On 9/14/2012 6:24 PM, J. Frank Parnell wrote:
>
>> 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.
Sure, but it makes a difference if you include a hundred files, each
with a single function, or if you just include a single file containing
all those functions.
It would make sense to group all the functions into semantic units and
put these into single files or classes. Then include the units you need.
Micha
--
http://mfesser.de/
Fotos | Blog | Flohmarkt
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179146 is a reply to message #179145] |
Sat, 15 September 2012 01:45 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 9/14/2012 7:43 PM, Michael Fesser wrote:
> .oO(Jerry Stuckle)
>
>> On 9/14/2012 6:24 PM, J. Frank Parnell wrote:
>>
>>> 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.
>
> Sure, but it makes a difference if you include a hundred files, each
> with a single function, or if you just include a single file containing
> all those functions.
>
> It would make sense to group all the functions into semantic units and
> put these into single files or classes. Then include the units you need.
>
> Micha
>
Not that much difference. The majority of the time is in the parsing,
not reading the files, especially since the files will most probably
already be in buffers.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179148 is a reply to message #179147] |
Sat, 15 September 2012 13:14 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 9/15/2012 2:08 AM, Anders Wegge Keller wrote:
> "J. Frank Parnell" <juglesh(at)gmail(dot)com> writes:
>
>> 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 may want to consider autoloading classes as needed. See
> http://php.net/manual/en/language.oop5.autoload.php
>
> This approach is of course dependent on using PHP5 *and* having an
> OO design.
>
Additionally, you're never sure which module you got. All kinds of
hard-to-diagnose things can happen when someone uploads a module of the
same name but earlier in the search path. You'll be trying to debug one
module while the system is using an entirely different module.
Plus the extra overhead of searching for the module, of course.
This is not a feature I recommend. It can cause many problems, and good
programming techniques render it pretty much unnecessary.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179149 is a reply to message #179148] |
Sat, 15 September 2012 21:41 |
Anders Wegge Keller
Messages: 30 Registered: May 2012
Karma: 0
|
Member |
|
|
Jerry Stuckle <jstucklex(at)attglobal(dot)net> writes:
> On 9/15/2012 2:08 AM, Anders Wegge Keller wrote:
>> "J. Frank Parnell" <juglesh(at)gmail(dot)com> writes:
>>
>>> 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 may want to consider autoloading classes as needed. See
>> http://php.net/manual/en/language.oop5.autoload.php
>>
>> This approach is of course dependent on using PHP5 *and* having an
>> OO design.
>>
>
> Additionally, you're never sure which module you got.
Speaking from experience?
> All kinds of hard-to-diagnose things can happen when someone uploads
> a module of the same name but earlier in the search path.
You let "someone" muck around with your code? Are you hosting at
GoDaddy or something like that?
> You'll be trying to debug one module while the system is using an
> entirely different module.
Only if you haven't got a clue...
> Plus the extra overhead of searching for the module, of course.
Surely, you are jesting. Or should I ask "Once unwitting, twice shy"?
> This is not a feature I recommend. It can cause many problems, and
> good programming techniques render it pretty much unnecessary.
I don't expect you to recognize a metric ton of clue, landing on your
head, but for the record let me tell the rest of the audience what the
self-proclaimed king of c.l.p is not smart enough to fiure out.
Wait for it...
Wait a bit more ...
The autoloader can be overridden by whatever code you care to call
when there is a request for an unknown class <rimshot />
[Simplified code ahead]
{classloader.php}
global $clClassMap;
$clClassMap = array(
/* Interfaces */
'iArticle' => 'classes/articleinterface.php',
/* Base classes */
'Page' => 'classes/pageobj.php',
'Request' => 'classes/request.php',
... <<The rest of whatever classes defined>>
);
class AutoLoader {
static function autoload ($classname) {
global $clClassMap;
$filename = false;
if ( isset ( $clClassMap[$classname] ) ) {
$filename=$clClassMap[$classname]
require("${ABSROOT}/${filename}");
} else {
return false; /* And throw an error. */
}
}
if ( function_exists ( 'spl_autoload_register' ) ) {
spl_autoload_register ( array('AutoLoader', 'autoload') );
} else {
function __autoload( $class ) {
AutoLoader::autoload( $class );
}
ini_set( 'unserialize_callback_func', '__autoload' );
}
{END classloader.php}
Everywhere else, require classloader.php, and use whatever classe you
want to. In case you forget to add them to $clClassMap, even Jerry
Stuckle should be smart enough to get what the error means. At least
after a few false starts. Also note that there is no noticable
overhead looking up an entry in a already-loaded array, compared to
the amortized overhead of the Stuckle-approved method of including and
parsing everything that has a remote chance of being relevant.
There might be a typo or two in the preceeding code. After all, it's
a simplified example. But I expect the majority of this group to be
able to work out the syntax errors. If not, please ask for
clarification.
--
/Wegge
Leder efter redundant peering af dk.*,linux.debian.*
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179150 is a reply to message #179149] |
Sat, 15 September 2012 22:06 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 9/15/2012 5:41 PM, Anders Wegge Keller wrote:
> Jerry Stuckle <jstucklex(at)attglobal(dot)net> writes:
>
>> On 9/15/2012 2:08 AM, Anders Wegge Keller wrote:
>>> "J. Frank Parnell" <juglesh(at)gmail(dot)com> writes:
>>>
>>>> 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 may want to consider autoloading classes as needed. See
>>> http://php.net/manual/en/language.oop5.autoload.php
>>>
>>> This approach is of course dependent on using PHP5 *and* having an
>>> OO design.
>>>
>>
>> Additionally, you're never sure which module you got.
>
> Speaking from experience?
>
Not personally, but I've seen it happen to others.
>> All kinds of hard-to-diagnose things can happen when someone uploads
>> a module of the same name but earlier in the search path.
>
> You let "someone" muck around with your code? Are you hosting at
> GoDaddy or something like that?
>
Nope, but I'm not necessarily the only developer on a project, nor am I
necessarily the only one who will ever work on the project. In fact,
chances are I will not be. I don't work on 5 page hobby sites.
>> You'll be trying to debug one module while the system is using an
>> entirely different module.
>
> Only if you haven't got a clue...
>
Which you don't...
>> Plus the extra overhead of searching for the module, of course.
>
> Surely, you are jesting. Or should I ask "Once unwitting, twice shy"?
>
Nope, it can take significant amount of time - I've seen some long paths
in the auto append.
>> This is not a feature I recommend. It can cause many problems, and
>> good programming techniques render it pretty much unnecessary.
>
> I don't expect you to recognize a metric ton of clue, landing on your
> head, but for the record let me tell the rest of the audience what the
> self-proclaimed king of c.l.p is not smart enough to fiure out.
>
> Wait for it...
>
> Wait a bit more ...
>
>
> The autoloader can be overridden by whatever code you care to call
> when there is a request for an unknown class <rimshot />
>
> [Simplified code ahead]
>
> {classloader.php}
>
> global $clClassMap;
>
> $clClassMap = array(
> /* Interfaces */
> 'iArticle' => 'classes/articleinterface.php',
>
> /* Base classes */
> 'Page' => 'classes/pageobj.php',
> 'Request' => 'classes/request.php',
>
> ... <<The rest of whatever classes defined>>
>
> );
>
>
> class AutoLoader {
> static function autoload ($classname) {
> global $clClassMap;
>
> $filename = false;
>
> if ( isset ( $clClassMap[$classname] ) ) {
> $filename=$clClassMap[$classname]
> require("${ABSROOT}/${filename}");
> } else {
> return false; /* And throw an error. */
> }
> }
>
> if ( function_exists ( 'spl_autoload_register' ) ) {
> spl_autoload_register ( array('AutoLoader', 'autoload') );
> } else {
> function __autoload( $class ) {
> AutoLoader::autoload( $class );
> }
>
> ini_set( 'unserialize_callback_func', '__autoload' );
> }
>
> {END classloader.php}
>
> Everywhere else, require classloader.php, and use whatever classe you
> want to. In case you forget to add them to $clClassMap, even Jerry
> Stuckle should be smart enough to get what the error means. At least
> after a few false starts. Also note that there is no noticable
> overhead looking up an entry in a already-loaded array, compared to
> the amortized overhead of the Stuckle-approved method of including and
> parsing everything that has a remote chance of being relevant.
>
> There might be a typo or two in the preceeding code. After all, it's
> a simplified example. But I expect the majority of this group to be
> able to work out the syntax errors. If not, please ask for
> clarification.
>
Sure, which means the interpreter has to load and parse even more code
unnecessarily. And there is no such thing as an "already-loaded array" -
every invocation of a script starts fresh.
But then we all know when you only work on 5 page sites which receive
100 page views/day, you can get away with this. But we know you'd never
be able to handle a decent sized site.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179151 is a reply to message #179150] |
Sat, 15 September 2012 22:10 |
Anders Wegge Keller
Messages: 30 Registered: May 2012
Karma: 0
|
Member |
|
|
Jerry Stuckle <jstucklex(at)attglobal(dot)net> writes:
> But then we all know when you only work on 5 page sites which
> receive 100 page views/day, you can get away with this. But we know
> you'd never be able to handle a decent sized site.
You are too easy. Code similar to this is the central part of
Mediawiki, the software that runs this small 100-hits/day-site, called
wikipedia.
Go get a new book of insults. The one you use is clearly outdated,
just as your grasp of reality, good coding practices for the 21st
century and project managing.
--
/Wegge
Leder efter redundant peering af dk.*,linux.debian.*
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179152 is a reply to message #179151] |
Sat, 15 September 2012 22:21 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 9/15/2012 6:10 PM, Anders Wegge Keller wrote:
> Jerry Stuckle <jstucklex(at)attglobal(dot)net> writes:
>
>> But then we all know when you only work on 5 page sites which
>> receive 100 page views/day, you can get away with this. But we know
>> you'd never be able to handle a decent sized site.
>
> You are too easy. Code similar to this is the central part of
> Mediawiki, the software that runs this small 100-hits/day-site, called
> wikipedia.
>
Sure - and look how many servers they need to run Mediawiki. Or are you
trying to claim YOU wrote Mediawiki?
> Go get a new book of insults. The one you use is clearly outdated,
> just as your grasp of reality, good coding practices for the 21st
> century and project managing.
>
Since when is the truth an insult? When you work on toy sites, you can
get by with toy coding.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179153 is a reply to message #179151] |
Sat, 15 September 2012 22:38 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
Anders Wegge Keller wrote:
> Jerry Stuckle <jstucklex(at)attglobal(dot)net> writes:
>
>> But then we all know when you only work on 5 page sites which
>> receive 100 page views/day, you can get away with this. But we know
>> you'd never be able to handle a decent sized site.
>
> You are too easy. Code similar to this is the central part of
> Mediawiki, the software that runs this small 100-hits/day-site, called
> wikipedia.
>
> Go get a new book of insults. The one you use is clearly outdated,
> just as your grasp of reality, good coding practices for the 21st
> century and project managing.
>
+1
--
Ineptocracy
(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
|
|
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179156 is a reply to message #179155] |
Sat, 15 September 2012 22:59 |
Anders Wegge Keller
Messages: 30 Registered: May 2012
Karma: 0
|
Member |
|
|
Jerry Stuckle <jstucklex(at)attglobal(dot)net> writes:
> On 9/15/2012 6:39 PM, Anders Wegge Keller wrote:
>> Jerry Stuckle <jstucklex(at)attglobal(dot)net> writes:
>>
>>> Since when is the truth an insult?
>>
>> That's why you are unable to insult me.
>>
>
> Glad you admit it's the truth.
No, that's just to get rid of you. Your truth is that of a little
man, stuck on coding 100 hits/day webshops, hosted on GoDaddy. Your
truth is a constant lack of self-esteem, constant craving for
recognition, and constant lack of basic concepts, such as amortized
complexity, big-O notation, and for the lack of a better word, grasp
of language.
You are unable to inslult me, because you are lying to yourself, when
you claim your half-witted cargo-cult programming as truth. Not
because I consider anything you say to be truth.
You are a case out of psychology 101, and I pity you for having such
a shitty life. Normally I ignore yoy, but whenever you happen to
respond to me, your post is lifted above the kill-file. I'm sorry if I
gave you the impression that I normally read your mistaken ramblings.
--
/Wegge
Leder efter redundant peering af dk.*,linux.debian.*
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179157 is a reply to message #179156] |
Sat, 15 September 2012 23:09 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
Anders Wegge Keller wrote:
> Jerry Stuckle <jstucklex(at)attglobal(dot)net> writes:
>
>> On 9/15/2012 6:39 PM, Anders Wegge Keller wrote:
>>> Jerry Stuckle <jstucklex(at)attglobal(dot)net> writes:
>>>
>>>> Since when is the truth an insult?
>>> That's why you are unable to insult me.
>>>
>> Glad you admit it's the truth.
>
> No, that's just to get rid of you. Your truth is that of a little
> man, stuck on coding 100 hits/day webshops, hosted on GoDaddy.
No. Jerry has never written any code at all.
No on this NG at least.
His mindset is almost pure COBOL large company, can't spot the asshole,
really.
Think about the time you worked for Systems Programming Inc. And there
was this one fat guy with pebble glasses who was so BAD at coding and so
anal that eventually they took him off writing code at all. He was
really GOOD at reading manuals even if he didn't understand much of what
he read, and so he found a place telling people what was in the manual
when they were too busy to look it up. Then he got sacked so he started
up a one man business offering training courses to TELL people what was
in the manuals. But eventually people found it wsa cheaper to buy the
manual and tell people to read it, so he vents his spleen here by
telling newbies what's in the manual.
A deeply bitter man whom life has passed by, because he was never
prepared to accept that he was crap at all the things he aspired to.
So he spends his life on total denial.
Your
> truth is a constant lack of self-esteem, constant craving for
> recognition, and constant lack of basic concepts, such as amortized
> complexity, big-O notation, and for the lack of a better word, grasp
> of language.
>
Go with the territory above
> You are unable to inslult me, because you are lying to yourself, when
> you claim your half-witted cargo-cult programming as truth. Not
> because I consider anything you say to be truth.
Indeed.
>
> You are a case out of psychology 101, and I pity you for having such
> a shitty life. Normally I ignore yoy, but whenever you happen to
> respond to me, your post is lifted above the kill-file. I'm sorry if I
> gave you the impression that I normally read your mistaken ramblings.
>
I don't. Life is too short.
--
Ineptocracy
(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179158 is a reply to message #179156] |
Sat, 15 September 2012 23:19 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 9/15/2012 6:59 PM, Anders Wegge Keller wrote:
> Jerry Stuckle <jstucklex(at)attglobal(dot)net> writes:
>
>> On 9/15/2012 6:39 PM, Anders Wegge Keller wrote:
>>> Jerry Stuckle <jstucklex(at)attglobal(dot)net> writes:
>>>
>>>> Since when is the truth an insult?
>>>
>>> That's why you are unable to insult me.
>>>
>>
>> Glad you admit it's the truth.
>
> No, that's just to get rid of you. Your truth is that of a little
> man, stuck on coding 100 hits/day webshops, hosted on GoDaddy. Your
> truth is a constant lack of self-esteem, constant craving for
> recognition, and constant lack of basic concepts, such as amortized
> complexity, big-O notation, and for the lack of a better word, grasp
> of language.
>
> You are unable to inslult me, because you are lying to yourself, when
> you claim your half-witted cargo-cult programming as truth. Not
> because I consider anything you say to be truth.
>
> You are a case out of psychology 101, and I pity you for having such
> a shitty life. Normally I ignore yoy, but whenever you happen to
> respond to me, your post is lifted above the kill-file. I'm sorry if I
> gave you the impression that I normally read your mistaken ramblings.
>
>
No, I'm not you. I have no websites hosted by GoDaddy. I do have my own
VPS's, though. And I have sites with > 1K pages (no, that's not one
page displaying 1K different rows in a database) and gets over 100K page
views (not hits, mind you) per day.
And you have no idea what complexity is. All you've ever done is
one-man projects of a few lines of code. How about a project with over
50 programmers on it that lasts for almost 3 years? Over 1M lines of
code. That's the kind of projects I've done in the past.
But it really makes me laugh that guys like you who get a toy site
running a few scripts and a 100 hits/day think you know everything.
You've already admitted you've never worked on a multi-programmer project.
You really have no idea what a real programmer does. And neither does
your fellow troll TNP (who has also proven he isn't the EE he claims to be).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179159 is a reply to message #179156] |
Sat, 15 September 2012 23:27 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 9/15/2012 6:59 PM, Anders Wegge Keller wrote:
<snip>
Oh, and about the Psychology 101 comment - you really shouldn't try to
pass your insecurities off on other people. You should get help for you
own problems.
But you're completely unable to admit that maybe, just maybe, someone
who's been programming longer than you've been alive might know
something you don't.
OTOH, I'm at the age now that I really don't give a damn about what
twerps like you think. My customers pay me very well for what I do -
because they know my capabilities. A lot more than you'll ever see,
that's for sure. But then I don't have to bid for work on the job sites.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179160 is a reply to message #179149] |
Sun, 16 September 2012 14:37 |
Peter H. Coffin
Messages: 245 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 15 Sep 2012 23:41:18 +0200, Anders Wegge Keller wrote:
> Jerry Stuckle <jstucklex(at)attglobal(dot)net> writes:
>
>> On 9/15/2012 2:08 AM, Anders Wegge Keller wrote:
>>> "J. Frank Parnell" <juglesh(at)gmail(dot)com> writes:
>>>
>>>> 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 may want to consider autoloading classes as needed. See
>>> http://php.net/manual/en/language.oop5.autoload.php
>>>
>>> This approach is of course dependent on using PHP5 *and* having an
>>> OO design.
>>>
>>
>> Additionally, you're never sure which module you got.
>
> Speaking from experience?
>
>> All kinds of hard-to-diagnose things can happen when someone uploads
>> a module of the same name but earlier in the search path.
>
> You let "someone" muck around with your code? Are you hosting at
> GoDaddy or something like that?
"Someone" could be another developer working on the same project of even
yourself comeing back to the code after ignoring it for a few years. An
awful lot of code looks completely foreign with three years on it, even
if one was completely familier with it back then.
--
31. All naive, busty tavern wenches in my realm will be replaced with
surly, world-weary waitresses who will provide no unexpected
reinforcement and/or romantic subplot for the hero or his sidekick.
--Peter Anspach's list of things to do as an Evil Overlord
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179161 is a reply to message #179160] |
Sun, 16 September 2012 15:32 |
Anders Wegge Keller
Messages: 30 Registered: May 2012
Karma: 0
|
Member |
|
|
"Peter H. Coffin" <hellsop(at)ninehells(dot)com> writes:
> "Someone" could be another developer working on the same project of
> even yourself comeing back to the code after ignoring it for a few
> years. An awful lot of code looks completely foreign with three
> years on it, even if one was completely familier with it back then.
In that case, you are equally fscked, using
require('somemodule.php'), when three years down the road, you add a
module with the same name elsewhere in the search path.
--
/Wegge
Leder efter redundant peering af dk.*,linux.debian.*
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179162 is a reply to message #179146] |
Sun, 16 September 2012 17:50 |
J. Frank Parnell
Messages: 12 Registered: January 2012
Karma: 0
|
Junior Member |
|
|
Ok, so I tested via:
function microtime_float(){
list($utime, $time) = explode(" ", microtime());
return ((float)$utime + (float)$time);
}
$script_start = microtime_float();
require '_funcs/_funcs.php';//this file does the globing, cacheing, including
$script_end = microtime_float();
echo "Script executed in ".bcsub($script_end, $script_start, 4)." seconds." ;
and I got
Script executed in 0.0200 seconds
Thats with either globing or reading the cache file (which backs up the statement that the glob doesnt add much)
Afa size and traffic of sites, wordpress sites, plenty of plugins and custom stuff. Traffic, some might be 100-500 page views/day.
Testing script execution for the whole page gave me around 2.5 seconds.
The whole front page takes around 2 seconds
On Friday, September 14, 2012 6:45:35 PM UTC-7, Jerry Stuckle wrote:
> On 9/14/2012 7:43 PM, Michael Fesser wrote:
>> .oO(Jerry Stuckle)
>>> On 9/14/2012 6:24 PM, J. Frank Parnell wrote:
>>>> 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.
> Not that much difference. The majority of the time is in the parsing,
> not reading the files, especially since the files will most probably
> already be in buffers.
>
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179163 is a reply to message #179162] |
Sun, 16 September 2012 21:45 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 9/16/2012 1:50 PM, J. Frank Parnell wrote:
> Ok, so I tested via:
> function microtime_float(){
> list($utime, $time) = explode(" ", microtime());
> return ((float)$utime + (float)$time);
> }
> $script_start = microtime_float();
> require '_funcs/_funcs.php';//this file does the globing, cacheing, including
> $script_end = microtime_float();
> echo "Script executed in ".bcsub($script_end, $script_start, 4)." seconds." ;
>
> and I got
> Script executed in 0.0200 seconds
> Thats with either globing or reading the cache file (which backs up the statement that the glob doesnt add much)
>
That's a HUGE amount of server time!
> Afa size and traffic of sites, wordpress sites, plenty of plugins and custom stuff. Traffic, some might be 100-500 page views/day.
>
> Testing script execution for the whole page gave me around 2.5 seconds.
>
Even worse!
> The whole front page takes around 2 seconds
Not good at all.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179164 is a reply to message #179161] |
Sun, 16 September 2012 21:46 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 9/16/2012 11:32 AM, Anders Wegge Keller wrote:
> "Peter H. Coffin" <hellsop(at)ninehells(dot)com> writes:
>
>> "Someone" could be another developer working on the same project of
>> even yourself comeing back to the code after ignoring it for a few
>> years. An awful lot of code looks completely foreign with three
>> years on it, even if one was completely familier with it back then.
>
> In that case, you are equally fscked, using
> require('somemodule.php'), when three years down the road, you add a
> module with the same name elsewhere in the search path.
>
That's because you don't use a search path. You give the location of
the file you're including (relative or absolute).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179165 is a reply to message #179163] |
Sun, 16 September 2012 23:00 |
J. Frank Parnell
Messages: 12 Registered: January 2012
Karma: 0
|
Junior Member |
|
|
On Sunday, September 16, 2012 2:45:40 PM UTC-7, Jerry Stuckle wrote:
> On 9/16/2012 1:50 PM, J. Frank Parnell wrote:
>
>> Ok, so I tested
>> and I got
>> Script executed in 0.0200 seconds
>> Thats with either globing or reading the cache file (which backs up the statement that the glob doesnt add much)
>
> That's a HUGE amount of server time!
>> Afa size and traffic of sites, wordpress sites, plenty of plugins and custom stuff. Traffic, some might be 100-500 page views/day.
>> Testing script execution for the whole page gave me around 2.5 seconds.
> Even worse!
>> The whole front page takes around 2 seconds
> Not good at all.
Another wp site, but without several facebook curls was .3 seconds (homepage), another .7, and a non wp site of mine, but still using my funcs includer was .03 seconds.
What do you think a good average should be, for a db driven site?
|
|
|
Re: How expensive is glob'ing a dir and including all the files? [message #179166 is a reply to message #179165] |
Mon, 17 September 2012 00:17 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 9/16/2012 7:00 PM, J. Frank Parnell wrote:
> On Sunday, September 16, 2012 2:45:40 PM UTC-7, Jerry Stuckle wrote:
>> On 9/16/2012 1:50 PM, J. Frank Parnell wrote:
>>
>>> Ok, so I tested
>>> and I got
>>> Script executed in 0.0200 seconds
>>> Thats with either globing or reading the cache file (which backs up the statement that the glob doesnt add much)
>>
>> That's a HUGE amount of server time!
>
>>> Afa size and traffic of sites, wordpress sites, plenty of plugins and custom stuff. Traffic, some might be 100-500 page views/day.
>>> Testing script execution for the whole page gave me around 2.5 seconds.
>> Even worse!
>>> The whole front page takes around 2 seconds
>> Not good at all.
>
> Another wp site, but without several facebook curls was .3 seconds (homepage), another .7, and a non wp site of mine, but still using my funcs includer was .03 seconds.
>
> What do you think a good average should be, for a db driven site?
>
Gawd, that's terrible!
Most of mine come in at under 0.001 seconds to server a page. A few run
a bit more, but not much.
I'm surprised shared hosting allows you to take that much CPU time.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|