Page 1 of 1

too many functions?

Posted: Wed Feb 07, 2007 4:35 am
by hame22
Hi

I have a large site containing many seperate includes files containing an number of functions.

All of these includes files are brought together by one main file that includes them all inc.functions.php and this is called by all the pages within my site

e.g. inc.functions.php looks like

Code: Select all

require_once('inc.dbfunctions.php');
require_once('queries.php');
require_once('inc.news.php');
require_once('inc.tj.php');
require_once('inc.pager.php');
require_once('inc.members.php');
require_once('inc.events.php');
My question (out of interest) is by including this file within each of my pages does this effect the performance of each page? I am concerened that pages may be calling on functions that it will not need.

I would be interested to hear your opinions

Thanks in advance

Posted: Wed Feb 07, 2007 4:44 am
by louie35
functions it will only do something when called by the script in your pages otherwise they will sit there waitting for the call.

You have them separated in few files.
Try to only include them if needed on that page.

Posted: Wed Feb 07, 2007 7:29 am
by s.dot
It will create a little bit of overhead. But if your pages are working slowly, this is most likely not the cause. The bit of overhead it causes wouldn't be much in comparison to say... a poorly designed query, or a poorly designed function that is executed.

Posted: Wed Feb 07, 2007 9:52 am
by jmut
hame22
Only way to determine if this slows you down is benchmarking/profiling.
As scottayy said .... performance bottleneck is not likely to be in you including lot of files.

Posted: Wed Feb 07, 2007 10:01 am
by hame22
thanks people, I don't have any performance issues with my site at present (touch wood)

It was just something that came into my mind that I wasnt sure about

thanks again!

Posted: Wed Feb 07, 2007 2:02 pm
by RobertGonzalez
Modularity and granularity are probably more important than the number of functions you have. If they are necessary, they are necessary. But are they optimized? That is the question to answer.