Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Performance enhancing on big files 3

Status
Not open for further replies.

bevan

Programmer
Jan 11, 2001
22
GB
Hi.
I have an asp page that reads maintenance and other similar issues from an Access2000 db. Some of the data is small such as the name of the caller, room number, telephone, but there is also large amounts of information kept in memo fields, such as an explanation of the problem (sometimes a couple of paragraphs) and what people have done so far to fix it (sometimes has many entries, often large).
As you would expect, it's a bit slow!
I have looked at some articles around the place (such as at 4guys) and these have helped a bit. They suggest stuff like using option explicit and other small things to increase speed.
My question is, how would performance differ between these two code examples? If at all?

1. using response.write

<% while not objRS.eof
response.write &quot;<table>&quot;
response.write &quot;<tr>&quot;
response.write &quot;<td>&quot; & objRS(&quot;progress&quot;) & &quot;</TD>&quot;
..... {other fields} ....
objRS.movenext
wend %>


2. without response.write

<% while not objRS.eof %>
<table>
<tr>
<td><%=objRS(&quot;progress&quot;)%></td>
..... {other fields} ....
<% objRS.movenext
wend %>


For all I know, they may perform exactly the same, but maybe there's something I don't know about.
Sorry the codes a bit rude but I'm only showing it as an example of the different ways to program what ends up the same in HTML.
Thanks heaps!

Thedon
 
I heard that you want to try to limit your usage of <%=someData%> in the page. The reason for this is that by doing
Code:
<%while i<5%>
<p><%=writeThis%></p>
<%
i = i + 1
loop%>
You incur a performance hit because the server sends the HTML tags out to the browser, then the server performs some more server-side stuff with the <%=writeThis%>. By having it go back and forth between the browser and the server, this can obviously add up. The desired method of doing something like this is to have the server write everything out, then send it to the browser.
eg:
Code:
<%while i<5
Response.write &quot;<p>&quot; &_
  writeThis&_
  &quot;</p>&quot;
i = i + 1
loop%>

This should save time because the trips to and from the client's browser are reduced, since the server processes the entire string then sends it out to the browser. At least this is what I heard.

Another thing I ran into was that it is typically better to use Response.write in the manner that I did above, than to make multiple calls to Response.write. If I remember right, the difference is only a couple of milliseconds, but in webtime that can really add up.

Now where did I get all this information? I think I got it from the asptoday.com site, but since they went to a subscription service, I can't check it for you.

hope this helps.
 
vasha20 is right. When you use <%-%>, each time you open a <% it has to go into a compile mode, and when you %> it goes out of compile mode into a write mode. It isn't really switching from a server to a browser, just form a write mode to a compile mode, but it takes a split-second each time it has to swich modes. Another thing you could do is minimize database calls and close and empty your recordsect and connection objects right after you are through with them. This keeps the server from having an open connection running when you don't need it (such as after the beginning of the page). When the page is sent out, it does destroy those connections, but if you don't need them for the whole page, why keep them open. Also, if you make database modifications using SQL strings instead of rs.AddNew and stuff like that, SQL string are a lot faster.

If you aren't worried about security too much either, you can use DSN-less connections, which are slightly faster than those that use DSN's. But, should someone be able to hack your server, they could gain your database's user name and password (since they have to be in your code for a DSN-less connection).

rs.close
set rs = nothing
cn.close
set cn = nothing

Hope some of that helps. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
Thanks guys,
You answered my question fully!
Now I just have to re-write some code...

The don
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top