3

I have about a 2000 line functions file, and I have realized I can split it up into a bout 4 files, and only include the one's required. At the moment it is very neat, and ideally I would like to leave it that way, however if speed increases can be gained I would like to only include the different sections on particular conditions.

My question is basically, would it be quicker to have an if statement and only load the php functions needed. Speed is a factor, as this library is called in an ajax polling situation.

1

1 Answer 1

6

best approach would be to divide all your code into meaningful folders/files/classes/functions. This serves the purpose of maintainable and readable code.
And then use some kind of cache like APC whih removes the problem of many includes/IOs almost completely.

Sign up to request clarification or add additional context in comments.

7 Comments

Split not for performance but to increase the quality of the code. +1
For the most part my includes, invoke function definitions more then variable definitions. My understanding was APC cached variables, not so much functions, is this correct?
@jezternz he actually does both, and it is a separate thing. caching variables you have to invoke by calling a function from within PHP, while caching your code happens automatically once you activate APC. You can regard this as two separate systems (which happens to share some code).
cheers Itay!, I may have to look into a custom server, as I don't know how much control my current web server gives me and I am not sure if I will be able to install APC, but while my project is in development I probably don't need to worry about it.
@jezternz how big is your project going to be (code base, number of users) you might be worried about what we call "premature optimization" (which is eval's brother).
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.