All in the <head>

– Ponderings & code by Drew McLellan –

– Live from The Internets since 2003 –

About

Optimizing ASP

17 July 2003

I spent a chunk of my day today optimizing an ASP script for performance. Here’s some observations I made that affect page build speed in a practical way.

The page I was working on was originally part of a prototype build to use an MS Access database. Therefore, the code was doing a rs.movefirst after opening each recordset on the page. This isn’t required for the SQL Server database we’re now using, and removing this line shaved a whole second off the build time. Neat.

After closing recordsets, it’s good practice to destroy the recordset object (by setting it to nothing) to release memory on the server. If you don’t manually destroy any objects, they get destroyed by the server on completion of building the page. Because of this, I have tended to be a bit sloppy in the past and allowed the server to do the hard work for me. What I discovered today was that manually destroying recordset objects as soon as you’re done with them has a positive impact on the page build speed. I’m not sure whether this has to do with the practicalities of resource handling or the efficiency of the server’s own trash collection code, but it certainly made a difference. I think I saved about 4/10 second on that alone.

If you think that saving one second here and 4/10 second there doesn’t really sound worth the effort, consider that an average ASP page will probably build in about 5/10 second …

- Drew McLellan

Tags

Comments

  1. § Cam McVey: Nice tips! Don’t know if you’re doing this, but if you have a recordset that you’re looping through, using GetRows() is a much more optimised technique. People can get fanatical about this (there’s an optimised asp code mailing list where GetRows() accounts for over 50% of the posts), but it can make a real difference. Your mileage may vary, of course, but it might shave more time off your page ...

Photographs

Work With Me

edgeofmyseat.com logo

At edgeofmyseat.com we build custom content management systems, ecommerce solutions and develop web apps.

Follow me

Recent Links

Affiliation

  • Web Standards Project
  • Britpack
  • 24 ways

I made

Perch - a really little cms

About Drew McLellan

Photo of Drew McLellan

Drew McLellan (@drewm) has been hacking on the web since around 1996 following an unfortunate incident with a margarine tub. Since then he’s spread himself between both front- and back-end development projects, and now is Director and Senior Web Developer at edgeofmyseat.com in Maidenhead, UK (GEO: 51.5217, -0.7177). Prior to this, Drew was a Web Developer for Yahoo!, and before that primarily worked as a technical lead within design and branding agencies for clients such as Nissan, Goodyear Dunlop, Siemens/Bosch, Cadburys, ICI Dulux and Virgin.net. Somewhere along the way, Drew managed to get himself embroiled with Dreamweaver and was made an early Macromedia Evangelist for that product. This lead to book deals, public appearances, fame, glory, and his eventual downfall.

Picking himself up again, Drew is now a strong advocate for best practises, and stood as Group Lead for The Web Standards Project 2006-08. He has had articles published by A List Apart, Adobe, and O’Reilly Media’s XML.com, mostly due to mistaken identity. Drew is a proponent of the lower-case semantic web, and is currently expending energies in the direction of the microformats movement, with particular interests in making parsers an off-the-shelf commodity and developing simple UI conventions. He writes here at all in the head and, with a little help from his friends, at 24 ways.