View Full Version : Viewing one file to view a page V.S. multiple files
05-04-2009, 12:57 AM
What's the difference (vis-a-vi performance), if any, to viewing a single file as a dynamic page compared to viewing multiple files?
One File will generate the HTML code for index view, member view, UI view, etc.
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.
05-04-2009, 03:14 AM
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.
05-04-2009, 03: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.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.