Author |
Topic |
|
Kerry
Average Member
USA
553 Posts |
Posted - 29 January 2001 : 17:12:44
|
Has anyone noted any good performance advantages of using includes? Certainly they allow for a certain amount of portability / reusability of code, but can they help / hinder perfomance significatly?
Example: <% if myVAR = "x" then %> <!-------BIG WHOPPIN INCLUDE FILE----------> <% end if %>
...or <% if myVAR = "x" then response.write"Here's where we'll actually put 1200 lines of code" end if %>
One line of thought tell me they'd perform about the same, another reasons that the first example would be faster (if myVAR = "y" or something other than X) because the 1200 lines wouldn't be looked at at all while the other method would still need to read through line-by-line.
Or am I over simplifying?
Thanks in advance, -Kerry
moved by reinsnitz on 03/14/2001 |
|
Doug G
Support Moderator
USA
6493 Posts |
Posted - 29 January 2001 : 20:53:37
|
quote: One line of thought tell me they'd perform about the same, another reasons that the first example would be faster (if myVAR = "y" or something other than X) because the 1200 lines wouldn't be looked at at all while the other method would still need to read through line-by-line.
Change your thinking. The only difference between the two examples is that the raw source code comes from one file in the first case and two files in the second case. The entire code is assembled before any preprocessing takes place, so the net result is the ASP processor looks at identical code.
Performance generally isn't the motivation to use include files, rather non-redundancy is the issue. Typically include files contain non page-specific code so only one copy needs to be maintained. Imagine life with 100 asp pages using the same big whoppin include file and you need to make some code changes to whatever is inside the include. Now imagine life if the actual code is embedded 100 different times in 100 different files.
====== Doug G ====== |
|
|
Kerry
Average Member
USA
553 Posts |
Posted - 29 January 2001 : 21:57:27
|
Thinking adjusted. -Thanks Doug
-Kerry
|
|
|
work mule
Senior Member
USA
1358 Posts |
Posted - 29 January 2001 : 23:00:48
|
I think Doug hit it right on the head when he said "non-redundancy is the issue".
One point I'd like to bring up is the practice of including the same file multiple times. I don't know if having the same include statement 5 times means that the server will load 5 copies of it or not. (I think it does.)
There are a couple of pages that include the same file multiple times. I did a search of all the Snitz .asp files for the include inc_footer.asp code and found 119 occurrences in 51 files. The worst offender is post_info.asp which includes inc_footer.asp 45 times.
%> <!--#INCLUDE FILE="inc_footer.asp" --> <%
Regardless of how many copies of the inc_footer.asp are loaded, the other thing to note that everytime you do this, there is a matter of the asp-html context switching too.
Would this work better wrapped into a sub? Replace all the instances of the above with something like a Call Footer() statement?
Sub Footer() %> <!--#INCLUDE FILE="inc_footer.asp" --> <% End Sub
Just something to think about.
|
|
|
Doug G
Support Moderator
USA
6493 Posts |
Posted - 30 January 2001 : 01:34:16
|
quote: Would this work better wrapped into a sub? Replace all the instances of the above with something like a Call Footer() statement?
Yes, yes it would. I know the many inc_footers has been brought up in the past, and it's not a good thing to do. You are correct, each include loads another copy so the code is redundantly included those many times, which does create a significant impact on the server cache memory.
====== Doug G ====== |
|
|
RichardKinser
Snitz Forums Admin
USA
16655 Posts |
Posted - 30 January 2001 : 02:10:39
|
I think this has been brought up before (at least I think I remember something about it)
In post_info.asp the <!--#INCLUDE FILE="inc_footer.asp" --> that are immediately after a line that includes Go_Result can be deleted.
The Go_Result sub outputs the message and already includes the <!--#INCLUDE FILE="inc_footer.asp" --> so it's just redundant. |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 30 January 2001 : 05:31:02
|
maybe we should bump this to bugs then, to have them sorted out in the forum code.
'Resistance is futile' |
|
|
Reinsnitz
Snitz Forums Admin
USA
3545 Posts |
Posted - 15 March 2001 : 10:15:03
|
continue discussion Here.
Reinsnitz (Mike) ><)))'> Need a Mod? "Therefore go and make disciples of all nations,..." Matthew 28:19a |
|
|
|
Topic |
|