Classic ASP

APR 14 2008

ASP Optimization Commandments
Author: Joe Maddalone

Neanderthals, evolve!

First off, let me say that I am still very fond of Classic ASP. Most projects I work on are entirely .NET at this point, however, there is a tremendous sense of pride over my mastery of classic ASP. When I need a very quick solution I am all too happy to load up notepad and just write it out without hunting down strange errors or methods that are not yet "old hat."

For the sake of passing on knowledge, and getting it out of the way, I must say, embrace .NET

With that in mind I am going to skip all the time proven testing data and get right to it. If you are using Classic ASP here is how to optimize for speed.

Option Explicit

Use it.

If that was not clear enough...Use it.

Concatenation

Don't do it.

If that was not clear enough...Don't do it.

Let's move on

Abandon All Ye Recordsets

Some prefer getString, however I am an avid fan of GetRows

set recs = conn.execute("select fields from table")
  if not recs.eof
      recsArray = recs.getrows()
      has recs = true
  end if
recs.close
set recs = nothing
with response
  if hasrecs then
      .write "<table>"
          for rows = 0 to ubound(recsArray,2) 'for each row
              .write "<tr>"        
                  for cols = 0 to ubound(recsArray,1)
                     .write "<td>"
                     .write recsArray(cols,rows)
                     .write "</td>"
                  next
              .write "</tr>"
          next
     .write "</table>"
  else
      .write "No records"
  end if
end with

I gurantee you will see a significant performance boost.

Fix Those Damn Tables

Fixed tables render faster than either those set at a percentage of it's parent or those, god forbid, not set at all

<table style="table-layout: fixed;">
<colgroup>
<col width="50" /><col width="50" /><col width="50" /><col width="50" />
</colgroup>
<tr>
<td>.... data... </td>
<td>.... data... </td>
<td>.... data... </td>
<td>.... data... </td>
</tr>
</table>

Less formatting

Trim back on the amount of HTML you need to output. It's 2008, for Pete's sake, get rid of all that inline styling.

Database-Fu

Call from your datasouce what it is that you need. No more "SELECT * FROM Table" when you only need two columns

Also, no more mid-loop secondary recordsets, get it the first time around, stick it in the array and call it a day.

Disk Reads Cause Bleeds

They do

In Summation

If you are working in Classic ASP or VBS and you are suffering from poor application speed, you now have the knowledge to fix it.

1 Comments


LATEST POSTS

Portfolio of the Future Just a random bit of sketching I was doing. Random things this month On my way to the interwebs I recall all I have learned today. CSV Splitter Reinventing the wheel one app at a time. Competetive Data Scraping Not yet an Olympic sport. Date Image Thing GDI+ to overprocess blog post dates!

ADS

MOST POPULAR

Multiple IEs in Windows Firefox Vs. The World Who Is Xperya? ActionScript Form Fields Quick Watermark IE 7 beta 2 standalone Text Link Ads

IP Address Tool Chicago Web Design Free Text Messaging