...

View Full Version : Viewing one file to view a page V.S. multiple files



Apothem
05-03-2009, 11:57 PM
What's the difference (vis-a-vi performance), if any, to viewing a single file as a dynamic page compared to viewing multiple files?

For instance:
One File will generate the HTML code for index view, member view, UI view, etc.
File: index.php
Multiple Files will generate separate HTML code for index view, member view, UI view, etc.
Files: index.php, member.php, user.php, etc.

Edit: Oops, I meant to post this in the PHP forum.

Fou-Lu
05-04-2009, 02:14 AM
Nothing substantial.
Byte for byte, I'd expect that in a single file would be faster. However, it reduces the reusability of you're code, so separate files is a better option.
For an example, I create a single file to be used as an interface or class. Though I could put multiple classes (keeping a 'group' of classes together that are similar), in the long run it would waste more space. If I only needed a 'user' type class in one project, I can save memory by not putting the 'usergroup' class in with it. Why load what we don't need?

Programming is always about trade offs.

venegal
05-04-2009, 02:24 AM
Well, Pykex, the way you are describing the situation is a bit different from the situation assumed in Fou-Lu's answer.

The way you describe it, there's always only one php file per http request, which means that the multiple files would be a few nanoseconds faster than the single file, which would have to do some case distinction.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum