Jump to content

Recommended Posts

I said, Gurus, but I accept the fact that I may be the only person that does not know the answer to this question.

 

I have a PHP application and have created several files such as:

 

output_functions.php

user_functions.php

data_functions.php

 

well, you get the picture.

 

So, will the size of these files have any effect on the total application(say in speed or anthing else)? Should I limit the size of these files? If they get to a certain size, should I break them up into 2 or more smaller files.

Link to comment
https://forums.phpfreaks.com/topic/180149-solved-question-for-the-gurus/
Share on other sites

Plus, if you have 1 huge file that you need to load, splitting it into 2 smaller files isn't going to magically make you not have to load the entire script anyways. It just (potentially) increases readability, and makes the code easier to navigate. Not that splitting up huge files is bad, but it won't really increase the speed of the script more than smart coding would

I once read a benchmark on inclusion, and it was clear that including one file was faster than many. In your case, I would include files as needed. For example, don't include everything at the top, use condition checks to determine if you need the includes. This will make your code faster. Now if you need all of them, then code optimization comes into play, database query optimization(if applicable), etc.

I pretty much concur with the above. I would split out the functions into separate files based upon which ones are used together. For example, if you have a set of functions that are only used for pages that include a form, for validation and such, then I would only load those functions on pages which include forms. Not knowing what functions are in those files or how they are used it's difficult to say if that is optimal.

 

But, I do like using smaller files with specific usage - it makes debugging and modifications much easier. For example, if you are needing to modify a function that is used to display a set of records, it is much safer if that file does not also include functions that insert/delete records. Otherwise you could accidentally instroduce a typo into other functions in that file and not know right away because you are only testing the display output.

 

Anyway, that's my two cents.

including code/files conditionally, along with a tight cache system (if applicable - using API's, redundant db queries, etc., a decent cache system is a time saver and a half), and your pages will be flyin'!

 

it is all about smart coding (i learn new techniques and figure out more efficient ways of coding almost on a daily basis).

 

bottom line is:  don't have code execute that doesn't need to be.  that's the basis of site optimization IMO.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.