too many functions?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

too many functions?

Post 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
User avatar
louie35
Forum Contributor
Posts: 144
Joined: Fri Jan 26, 2007 8:40 am
Location: Dublin
Contact:

Post 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.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post 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.
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Post 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!
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
Post Reply