Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 code optimization
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

stealthc
Starting Member

21 Posts

Posted - 27 May 2001 :  20:46:19  Show Profile
Any tips for optimizing some code. I'm just brushing over it and making sure my variables are set to equal nothing, not sure if that's necessary, but I just wanna hear some thoughts on getting things to run smoother and faster.


camusflage
Starting Member

USA
26 Posts

Posted - 28 May 2001 :  20:12:42  Show Profile
Hrmmm. A couple of tips from experience...

ALWAYS use option explicit. MS says you get about a 10% performance boost, plus the added benefit of being able to debug when you fat finger variables.

Try not to break from asp to html to asp a lot. Context switching is expensive. If you just need a snippet of html from your asp logic, use response.write instead.

Buffer output. Always. This is nicer to the network subsystem, and allows your page to process before doing any redirection. Some browsers don't like receiving information before being told to go somewhere else. Before you start doing something you already know might take a while to process, do a response.flush so that the user isn't sitting there thinking nothing's happening.

When possible, use OLEDB vs ODBC. In recent iterations of MDAC (1.5+, IIRC), ODBC anymore is just a front-end to OLEDB. Cut out the middleman and use OLEDB directly.

If given the choice between building sql calls in asp and using a stored procedure to run it, always go with the SP. Precompiled statements are approx. 20% faster than dynamic statements.

If you use objects, try to always set them to nothing (you said you're doing it). This isn't so much for optimization as it is cleaning up after yourself. Although ASP closes everything at the end of page execution, sometimes it doesn't get all the bits. Those bits add up over time, and become a memory leak in your application. While I suppose this can happen with simple variables, it's more problematic with objects.

If it's a constant, define it as one. Constants have lower memory overhead and faster creation time than do variables. const conName = "constant"

If you're using code to do a particular function, and you have a component available to do the same thing, in most cases, it's better to use the component instead of the code. Compiled code is an order of magnitude faster than scripted code.

Mike



Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.32 seconds. Powered By: Snitz Forums 2000 Version 3.4.07