Two related "performance" questions

This is a discussion on Two related "performance" questions within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I'm working on a program that permits a web site admin to enable either or both of its two ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-24-2007
Michael Daly
 
Posts: n/a
Default Two related "performance" questions

I'm working on a program that permits a web site admin to enable either
or both of its two features. Both features have a reasonable amount of
code.

So - is it likely that someone will complain that having both sets of
code loaded when only one of the features is enabled will reduce
performance? Is there a significant advantage to splitting the code so
that only one feature is loaded to run when only one feature is enabled?
The php file is about 30KB (both features).

Second - I tend to put a lot of comments in my code. In terms of file
size, there is often more lines of comments than lines of code (unless
the code is relatively trivial). Similarly - is someone likely to grump
that loading all that text at run rime is inefficient?

Mike
Reply With Quote
  #2 (permalink)  
Old 03-25-2007
shimmyshack
 
Posts: n/a
Default Re: Two related "performance" questions

On 24 Mar, 21:50, Michael Daly <MichaelD...@foo.bar> wrote:
> I'm working on a program that permits a web site admin to enable either
> or both of its two features. Both features have a reasonable amount of
> code.
>
> So - is it likely that someone will complain that having both sets of
> code loaded when only one of the features is enabled will reduce
> performance? Is there a significant advantage to splitting the code so
> that only one feature is loaded to run when only one feature is enabled?
> The php file is about 30KB (both features).
>

not really

> Second - I tend to put a lot of comments in my code. In terms of file
> size, there is often more lines of comments than lines of code (unless
> the code is relatively trivial). Similarly - is someone likely to grump
> that loading all that text at run rime is inefficient?


and no
>
> Mike


but in general for other reasons it is a good idea to modularise your
code, something like jpgraph - a huge set of classes that generates
various types of graphs, simply separates its clsses according to the
type of graph, its a split that makes sense to coders implementing it
at the coal face, and to maintainters. It would be a nice little
project to convert to OO, if not already, and yeah try separating it.

Reply With Quote
  #3 (permalink)  
Old 03-25-2007
Michael Daly
 
Posts: n/a
Default Re: Two related "performance" questions

shimmyshack wrote:

Thanks for the info.

> but in general for other reasons it is a good idea to modularise your
> code, something like jpgraph


Yeah - I've been sloppy up to now and all classes are defined in a
single file. I intend to split it into one file per class. However, I
figure that with all the require_once statements, at run time it will be
like loading a single big file anyway, no?

Mike
Reply With Quote
  #4 (permalink)  
Old 03-25-2007
ZeldorBlat
 
Posts: n/a
Default Re: Two related "performance" questions

On Mar 25, 1:03 pm, Michael Daly <MichaelD...@foo.bar> wrote:
> shimmyshack wrote:
>
> Thanks for the info.
>
> > but in general for other reasons it is a good idea to modularise your
> > code, something like jpgraph

>
> Yeah - I've been sloppy up to now and all classes are defined in a
> single file. I intend to split it into one file per class. However, I
> figure that with all the require_once statements, at run time it will be
> like loading a single big file anyway, no?
>
> Mike


That's what __autload is for:

<http://www.php.net/autoload>

Here's the idea: when a class is referenced and it isn't yet defined,
the __autoload function is called with the class name. This gives you
an opportunity to load it. Furthermore, you'll only end up loading
what you need and you won't need all those require_once() statements.

All my classes live in their own files where the file is named after
the class. I have a file called autoload.php that I include at the
top of all my pages. Inside I have something like this:

if(!function_exists('__autoload')) {
function __autoload($class_name) {
require_once $class_name . '.php';
}
}

Reply With Quote
  #5 (permalink)  
Old 03-25-2007
Michael Daly
 
Posts: n/a
Default Re: Two related "performance" questions

ZeldorBlat wrote:

> That's what __autload is for:


Thanks - that's useful info. I'll check it out.

Mike
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:41 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0