473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ASP Classic Performance Question

I'm maintaining an ASP Classic file that has HTML withing
Response.Write methods...such as.
<%
Response.Write "<table><tr><td>"
Response.Write testVariable
Response.Write "</td></tr></table>"
%>

Would their be a performance hit if I were to write this instead?

<table><tr><td><%=testVariable%></td></tr></table>

I think, no, but I need some confirmation.

Thanks for any advice/suggestions.

Sep 21 '06 #1
14 2184
That is what i usually do. works fine for me.
James Jones


"Merovingian" <st***********@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
I'm maintaining an ASP Classic file that has HTML withing
Response.Write methods...such as.
<%
Response.Write "<table><tr><td>"
Response.Write testVariable
Response.Write "</td></tr></table>"
%>

Would their be a performance hit if I were to write this instead?

<table><tr><td><%=testVariable%></td></tr></table>

I think, no, but I need some confirmation.

Thanks for any advice/suggestions.

Sep 21 '06 #2
Merovingian wrote:
I'm maintaining an ASP Classic file that has HTML withing
Response.Write methods...such as.
<%
Response.Write "<table><tr><td>"
Response.Write testVariable
Response.Write "</td></tr></table>"
%>

Would their be a performance hit if I were to write this instead?

<table><tr><td><%=testVariable%></td></tr></table>

I think, no, but I need some confirmation.
No. I think in IIS4, there used to be, but that is no longer a factor.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Sep 21 '06 #3
Thanks Bob!

Bob Barrows [MVP] wrote:
Merovingian wrote:
I'm maintaining an ASP Classic file that has HTML withing
Response.Write methods...such as.
<%
Response.Write "<table><tr><td>"
Response.Write testVariable
Response.Write "</td></tr></table>"
%>

Would their be a performance hit if I were to write this instead?

<table><tr><td><%=testVariable%></td></tr></table>

I think, no, but I need some confirmation.
No. I think in IIS4, there used to be, but that is no longer a factor.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Sep 21 '06 #4
Could I get some links to back up the performance between the two
examples?

Merovingian wrote:
Thanks Bob!

Bob Barrows [MVP] wrote:
Merovingian wrote:
I'm maintaining an ASP Classic file that has HTML withing
Response.Write methods...such as.
>
>
<%
Response.Write "<table><tr><td>"
Response.Write testVariable
Response.Write "</td></tr></table>"
%>
>
Would their be a performance hit if I were to write this instead?
>
<table><tr><td><%=testVariable%></td></tr></table>
>
I think, no, but I need some confirmation.
>
No. I think in IIS4, there used to be, but that is no longer a factor.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Sep 21 '06 #5
there's not going to be a difference to worry about, but you could use a timestamp to note start of page processing and end of page
processing then calc difference.
personally, I think before attempting to solve a performance problem, perhaps you should demonstrate that the problem exists...
"Merovingian" <st***********@gmail.comwrote in message news:11**********************@b28g2000cwb.googlegr oups.com...
Could I get some links to back up the performance between the two
examples?

Merovingian wrote:
>Thanks Bob!

Bob Barrows [MVP] wrote:
Merovingian wrote:
I'm maintaining an ASP Classic file that has HTML withing
Response.Write methods...such as.
<%
Response.Write "<table><tr><td>"
Response.Write testVariable
Response.Write "</td></tr></table>"
%>

Would their be a performance hit if I were to write this instead?

<table><tr><td><%=testVariable%></td></tr></table>

I think, no, but I need some confirmation.

No. I think in IIS4, there used to be, but that is no longer a factor.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Sep 21 '06 #6
This is a topic of discussion between me and another developer and I
can't seem to convey that it makes no difference except that the
readability and mantainability of the code is easier without all the
markup in the ASP tag delimiters. Personally, we wouldn't be having
this conversation if we were using ASP.NET.

Jon Paal wrote:
there's not going to be a difference to worry about, but you could use a timestamp to note start of page processing and end of page
processing then calc difference.
personally, I think before attempting to solve a performance problem, perhaps you should demonstrate that the problem exists...
"Merovingian" <st***********@gmail.comwrote in message news:11**********************@b28g2000cwb.googlegr oups.com...
Could I get some links to back up the performance between the two
examples?

Merovingian wrote:
Thanks Bob!

Bob Barrows [MVP] wrote:
Merovingian wrote:
I'm maintaining an ASP Classic file that has HTML withing
Response.Write methods...such as.
>
>
<%
Response.Write "<table><tr><td>"
Response.Write testVariable
Response.Write "</td></tr></table>"
%>
>
Would their be a performance hit if I were to write this instead?
>
<table><tr><td><%=testVariable%></td></tr></table>
>
I think, no, but I need some confirmation.
>
No. I think in IIS4, there used to be, but that is no longer a factor.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Sep 21 '06 #7
I doubt a cite* would convince him. I suspect the only thing that would
probably convince him is a test. So take 5 minutes and create a test package
and run it.
*I have no cites. I really don't remember where I read that the performance
issue was solved with IIS 5.1. You may find someone with a link in the iis
group.

Merovingian wrote:
This is a topic of discussion between me and another developer and I
can't seem to convey that it makes no difference except that the
readability and mantainability of the code is easier without all the
markup in the ASP tag delimiters. Personally, we wouldn't be having
this conversation if we were using ASP.NET.

Jon Paal wrote:
>there's not going to be a difference to worry about, but you could
use a timestamp to note start of page processing and end of page
processing then calc difference.
personally, I think before attempting to solve a performance
problem, perhaps you should demonstrate that the problem exists...
"Merovingian" <st***********@gmail.comwrote in message
news:11**********************@b28g2000cwb.googleg roups.com...
>>Could I get some links to back up the performance between the two
examples?

Merovingian wrote:
Thanks Bob!

Bob Barrows [MVP] wrote:
Merovingian wrote:
>I'm maintaining an ASP Classic file that has HTML withing
>Response.Write methods...such as.
>>
>>
><%
>Response.Write "<table><tr><td>"
>Response.Write testVariable
>Response.Write "</td></tr></table>"
>%>
>>
>Would their be a performance hit if I were to write this instead?
>>
><table><tr><td><%=testVariable%></td></tr></table>
>>
>I think, no, but I need some confirmation.
>>
No. I think in IIS4, there used to be, but that is no longer a
factor. --
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will
get a
quicker response by posting to the newsgroup.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Sep 22 '06 #8
"Merovingian" <st***********@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
I'm maintaining an ASP Classic file that has HTML withing
Response.Write methods...such as.

<%
Response.Write "<table><tr><td>"
Response.Write testVariable
Response.Write "</td></tr></table>"
%>

Would their be a performance hit if I were to write this instead?

<table><tr><td><%=testVariable%></td></tr></table>

I think, no, but I need some confirmation.

Thanks for any advice/suggestions.

VBScript String Concatenation
(And Why It Should Be Avoided Like The Plague)
http://www.asp101.com/articles/marcu...on/default.asp
"... here are the results of the benchmarks ..."
How do I make my ASP pages more efficient?
http://classicasp.aspfaq.com/general...s-more-efficie
nt.html
"Don't generate large strings in single variables -- concatenation is very
expensive."
Here's what I do:

<%
Dim arrSTR()
ReDim arrSTR(100)
Dim intSTR
intSTR = 0
Dim strSTR
'*
Append "<table border='0'>"
Append "<tr>"
Append " <th>`Hello World!`<hr></th>"
Append "</tr>"
Append "</table>"
'*
Response.Write Concat()

Sub Append(strSTR)
'****
'* Append strings to array entries ReDim as needed; (see "Concat()").
'****
strSTR = strSTR & ""
If intSTR UBound(arrSTR) Then
ReDim Preserve arrSTR(UBound(arrSTR) + 100)
End If
arrSTR(intSTR) = strSTR & vbCrLf
intSTR = intSTR + 1
End Sub

Function Concat()
'****
'* Concatenates array entries into a single string; (see "Append()").
'****
Redim Preserve arrSTR(intSTR)
Concat = Replace(Join(arrSTR,""),"`",Chr(34))
Erase arrSTR
ReDim arrSTR(100)
intSTR = 0
End Function
%>

Only one Response.Write() and the code is lot more readable.
Sep 22 '06 #9
Merovingian wrote:
I'm maintaining an ASP Classic file that has HTML withing
Response.Write methods...such as.
<%
Response.Write "<table><tr><td>"
Response.Write testVariable
Response.Write "</td></tr></table>"
%>
Would their be a performance hit if I were to write this instead?
<table><tr><td><%=testVariable%></td></tr></table>
No.
An ASP page is, on the first request for that page, compiled to p-code,
executed and the p-code cached for subsequent executions. During the
compile step, any embedded HTML is replaced by a call to the
(unpublished) Response.WriteBlock(N) method. Here N refers to the Nth
"block" of embedded HTML. Blocks numbers start with 0. You can test this
by writing explicit calls to Response.WriteBlock() for your edification.

Consequently output is either from a Response.Write() call or a
Response.WriteBlock() call. Any difference in speed is insignificant.

We've discussed this before many times on these newsgroups:
http://groups.google.com/groups?as_q...=2006&safe=off

Further details on how ASP is compiled and executed
See in particular "Appendix 3: ASP Caching":
http://www.microsoft.com/technet/pro...on130121120120

Explanation of compilation with examples of ASP p-code:
http://groups.google.com/group/micro...e=source&hl=en
Sep 22 '06 #10
http://www.microsoft.com/technet/pro...ips.mspx#EHJAC

Apparently it is more efficient to put your HTML into Response.Writes
while in a loop. It's still hard for me to accept it.

Michael D. Kersey wrote:
Merovingian wrote:
I'm maintaining an ASP Classic file that has HTML withing
Response.Write methods...such as.
<%
Response.Write "<table><tr><td>"
Response.Write testVariable
Response.Write "</td></tr></table>"
%>
Would their be a performance hit if I were to write this instead?
<table><tr><td><%=testVariable%></td></tr></table>

No.
An ASP page is, on the first request for that page, compiled to p-code,
executed and the p-code cached for subsequent executions. During the
compile step, any embedded HTML is replaced by a call to the
(unpublished) Response.WriteBlock(N) method. Here N refers to the Nth
"block" of embedded HTML. Blocks numbers start with 0. You can test this
by writing explicit calls to Response.WriteBlock() for your edification.

Consequently output is either from a Response.Write() call or a
Response.WriteBlock() call. Any difference in speed is insignificant.

We've discussed this before many times on these newsgroups:
http://groups.google.com/groups?as_q...=2006&safe=off

Further details on how ASP is compiled and executed
See in particular "Appendix 3: ASP Caching":
http://www.microsoft.com/technet/pro...on130121120120

Explanation of compilation with examples of ASP p-code:
http://groups.google.com/group/micro...e=source&hl=en
Sep 22 '06 #11

"Merovingian" <st***********@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
>
http://www.microsoft.com/technet/pro...ips.mspx#EHJAC
>
Apparently it is more efficient to put your HTML into Response.Writes
while in a loop. It's still hard for me to accept it.
Certainly with response.buffer off it will be slower but with response
buffering on I seriously doubt that using inline html would be slower than a
loop of response writes.

The premise of the linked item above is that multiple calls a Response.Write
(or Response.WriteBlock) is slower than a single call. However in order to
modify your code to make a single call you would need to perform string
concatenation in Script. As Michael has already pointed out this is
(relatively at the level we are discussing) pretty slow especially in
VBScript.

There is another factor to consider. String literals encoded in to ASP
Script code will get compiled into the p-code as Unicode strings (these
strings are typically twice as big as they were in the original file). When
response.write receives this unicode string it needs to perform a conversion
on the string to the code page current for the response. In line content
OTH will be sent as a block bytes as is in the file no conversion to or from
unicode will be performed.

Hence I suspect that if you could build a test senstive enough to discover
the differences whilst being sure that other factors are fully accounted for
(which I doubt can truely be done) then you'd find that inline HTML is
faster (with buffering on.)

There is also yet another factor to bear in mind if you need to generate
multilingual output by using UTF-8 encoded files. String literals in script
in a UTF-8 encoded file must be strictly with in the ASCII character set.

Anthony.
Michael D. Kersey wrote:
Merovingian wrote:
I'm maintaining an ASP Classic file that has HTML withing
Response.Write methods...such as.
<%
Response.Write "<table><tr><td>"
Response.Write testVariable
Response.Write "</td></tr></table>"
%>
Would their be a performance hit if I were to write this instead?
<table><tr><td><%=testVariable%></td></tr></table>
No.
An ASP page is, on the first request for that page, compiled to p-code,
executed and the p-code cached for subsequent executions. During the
compile step, any embedded HTML is replaced by a call to the
(unpublished) Response.WriteBlock(N) method. Here N refers to the Nth
"block" of embedded HTML. Blocks numbers start with 0. You can test this
by writing explicit calls to Response.WriteBlock() for your edification.

Consequently output is either from a Response.Write() call or a
Response.WriteBlock() call. Any difference in speed is insignificant.

We've discussed this before many times on these newsgroups:
http://groups.google.com/groups?as_q...=2006&safe=off

Further details on how ASP is compiled and executed
See in particular "Appendix 3: ASP Caching":
http://www.microsoft.com/technet/pro...on130121120120

Explanation of compilation with examples of ASP p-code:
http://groups.google.com/group/micro...e=source&hl=en
>

Sep 22 '06 #12
Merovingian wrote:
This is a topic of discussion between me and another developer
and I can't seem to convey that it makes no difference except
that the readability and mantainability of the code is easier
without all the markup in the ASP tag delimiters. Personally,
we wouldn't be having this conversation if we were using ASP.NET.
With the differences as small as they are (if they exist at all),
readability and maintainability ought to be enough, period. Once again, I
quote Eric Lippert:

"If you care about maximizing performance, using a late-bound
unoptimized bytecode-interpreted dynamically-typed language
is probably a bad choice"

There is little to suggest that context-switching has been an issue at all
since IIS4. I assert that the TechNet article was written for IIS4 and left
unchanged for the IIS5 documentation. I submit as evidence this phrase: "If
response buffering is not turned on". Had the article been written for IIS5,
it would be: "If response buffering is turned off".

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Sep 22 '06 #13
Merovingian wrote:
http://www.microsoft.com/technet/pro...ips.mspx#EHJAC
The article is incorrect in this regard. I believe it is incorrect for
versions of IIS back to at least IIS3 (my first experience with IIS). I
don't know about earlier versions of IIS. I believe it conflates two
distinct topics:
a. Buffered of output in ASP and
b. use of Response.Write() vs. embedded HTML (Response.WriteBlock())
Finally I believe it assumes an incorrect execution model of ASP.

Concerning Tip 15 of the article specifically:
1. The first sentence addresses buffering I/O and is orthogonal to the
question of whether Response.Write or embedded HTML
(Response.WriteBlock()) is faster.

2. The third sentence
Also, interspersing small amounts of script and HTML causes switching between the script engine and HTML, reducing performance.
is nonsense.

Why? Because there is no "switching between the script engine and HTML".
In your example, all output to the client browser from ASP is generated
by either an explicit Response.Write() call or, in the case of embedded
HTML, a Response.WriteBlock() call.

There _is_ true context switching in the usual sense, wherein the
operating system interrupts execution of the ASP script engine p-code to
handle I/O. But that would occur regardless of whether one uses
Response.Write() or embedded HTML (Response.WriteBlock()) in their code.
And it would occur to the same degree for either.

So don't believe everything you read on Microsoft's site (thanks to
Anthony Jones). And you can always test and see for yourself. Don't
become dependent on authoritative references, they can be wrong.
Sep 23 '06 #14

"Anthony Jones" <An*@yadayadayada.comwrote in message
news:Oi**************@TK2MSFTNGP04.phx.gbl...
>
"Merovingian" <st***********@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
>>
http://www.microsoft.com/technet/pro...ips.mspx#EHJAC
>>
Apparently it is more efficient to put your HTML into Response.Writes
while in a loop. It's still hard for me to accept it.

Certainly with response.buffer off it will be slower but with response
buffering on I seriously doubt that using inline html would be slower than
a
loop of response writes.

The premise of the linked item above is that multiple calls a
Response.Write
(or Response.WriteBlock) is slower than a single call. However in order
to
modify your code to make a single call you would need to perform string
concatenation in Script. As Michael has already pointed out this is
(relatively at the level we are discussing) pretty slow especially in
VBScript.

There is another factor to consider. String literals encoded in to ASP
Script code will get compiled into the p-code as Unicode strings (these
strings are typically twice as big as they were in the original file).
When
response.write receives this unicode string it needs to perform a
conversion
on the string to the code page current for the response. In line content
OTH will be sent as a block bytes as is in the file no conversion to or
from
unicode will be performed.

Hence I suspect that if you could build a test senstive enough to discover
the differences whilst being sure that other factors are fully accounted
for
(which I doubt can truely be done)
Actually, there is a way, I wrote a small COM object that calls the
QueryPerformanceCounters Win32 API, does the math between start and end, and
casts its returns from 64 bit int to double. It's effective resolution is
equal to the CPU clock speed on modern hardware, thus making it
theoretically capable of timing sub-microsecond intervals (skewed slightly
by COM call overhead, of course.)

It has proven adequate for profiling ASP script code; coincidentally, I
originally wrote it for precisely that purpose. :-)

http://www.databoundzone.com/project...imer/index.htm
-Mark

then you'd find that inline HTML is
faster (with buffering on.)

There is also yet another factor to bear in mind if you need to generate
multilingual output by using UTF-8 encoded files. String literals in
script
in a UTF-8 encoded file must be strictly with in the ASCII character set.

Anthony.
>Michael D. Kersey wrote:
Merovingian wrote:
I'm maintaining an ASP Classic file that has HTML withing
Response.Write methods...such as.
<%
Response.Write "<table><tr><td>"
Response.Write testVariable
Response.Write "</td></tr></table>"
%>
Would their be a performance hit if I were to write this instead?
<table><tr><td><%=testVariable%></td></tr></table>

No.
An ASP page is, on the first request for that page, compiled to p-code,
executed and the p-code cached for subsequent executions. During the
compile step, any embedded HTML is replaced by a call to the
(unpublished) Response.WriteBlock(N) method. Here N refers to the Nth
"block" of embedded HTML. Blocks numbers start with 0. You can test
this
by writing explicit calls to Response.WriteBlock() for your
edification.

Consequently output is either from a Response.Write() call or a
Response.WriteBlock() call. Any difference in speed is insignificant.

We've discussed this before many times on these newsgroups:
http://groups.google.com/groups?as_q...=2006&safe=off
>
Further details on how ASP is compiled and executed
See in particular "Appendix 3: ASP Caching":
http://www.microsoft.com/technet/pro...on130121120120
>
Explanation of compilation with examples of ASP p-code:
http://groups.google.com/group/micro...e=source&hl=en
>>


Sep 24 '06 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Adi Schwarz | last post by:
I was asking myself what solution is better considering performance. I want to create some classes depending on a varable (for different languages). Of course, if the classes are huge I write...
2
by: inna | last post by:
Hello. I have query performance question. I need to optimize procedure CREATE PROCEDURE dbo.SECUQUSRCOMPACCES @P1 VARCHAR(50), @P2 INTEGER AS DECLARE @IORGANIZATIONID INTEGER EXECUTE...
7
by: Randell D. | last post by:
Folks, I have a Javascript performance question that I might have problems explaining... In PHP, better performance can be obtained dealing directly with a variable, as opposed to an element...
8
by: Együd Csaba | last post by:
Hi All, how can I improve the query performance in the following situation: I have a big (4.5+ million rows) table. One query takes approx. 9 sec to finish resulting ~10000 rows. But if I run...
6
by: Mike | last post by:
Lets just say my app is done HOO HOO. Now, I'm accessing the database via a web service and one thing i noticed that my app is running real slow. When I first started working on the app is ran...
12
by: mcp6453 | last post by:
My small company has a web site that is developed in "Classic ASP", which is, I'm told, different from just "ASP". It is clear to me that we are not using ASP.NET. The site is hosted on a shared...
30
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
0
by: Aykut Canturk | last post by:
As all we know there are 2 ways for binding gridview to sql table. using sqldata adapter and using code. What I want to know is, in large tables, is there a perfomance difference. When using code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.