[php] Function Efficiency

taekwondokid42

New Member
Messages
268
Reaction score
0
Points
0
What would be more efficient:

One script that is ~300 lines long, but if-else statments means that the server would only have to run ~100 of them

Or

One script that is ~50 lines long, and then re-directs the browser to another script that is ~100 lines long, and the server would have to run all of them.

Or

does it matter?
 

cowctcat

New Member
Messages
401
Reaction score
0
Points
0
It really comes up to what connection speed do you think your visitors will have. I would say the safe bet is the first option.
 

taekwondokid42

New Member
Messages
268
Reaction score
0
Points
0
Ok, I'll go with that.

I honestly have no idea which is more efficient, but my target is users with slower computers and connection speeds.
 

konekt

New Member
Messages
100
Reaction score
0
Points
0
The first one comes of as much more efficient. Lines of code do not really denote efficiency, what those lines do does, however. Redirecting means that the user has to be re-served by the server, so if they have a slow connection it would be like loading twice as opposed to loading everything once.

Loading time is not a linear relationship with code lines; when you request code you actually spend a little time speaking with the server. I believe you go back and forth eight times before the server ever sends anything, so imagine having to do that twice with a slow connection.
 
Top