Tutorials to .com

Tutorials to .com » Asp » Optimization » 5 speed skills ASP

5 speed skills ASP

Print View , by: iSee ,Total views: 14 ,Word Count: 1008 ,Date: Fri, 17 Apr 2009 Time: 8:34 PM

One skill: To improve the collection efficiency of the use of Request

  visit a collection of asp to extract a value is time-consuming, taking up the process of computing resources. Because it contains a series of operations related to the collection of search, this visit to a local variable to be much slower. Therefore, if it intends to use the page several times a collection Request value, consideration should be given to a local variable storage. For example, the code written in the form of the following scripting engine to speed up the processing speed:

strTitle = Request.Form ( "Title")
strFirstName = Request.Form ( "FirstName")
strLastName = Request.Form ( "LastName")
If Len (strTitle) Then strTitle = strTitle & ""
If strFirstName = "" Then strFullName = strTitle & "" & strLastName
Elseif Len (strFirstName) = 1 Then
strFullName = strTitle & strFirstName & "." & strLastName
strFullName = strTitle & strFirstName & "" & strLastName
End If

  2 techniques: direct access to the appropriate collection

  If it is not no choice, otherwise, do not use strPage = Request ( "page") in such a way to obtain the parameters, because this will be the order of search a collection of all-QueryString, Form, Cookies, ClientCertificate, ServerVarible found until the first name matching. To do so than a collection of direct access to appropriate low efficiency, and is unsafe, unless it can absolutely guarantee that this value will not appear in another collection.
For example, customers may want to search the WEB server name in the request, which passed in the query Request.ServerVarables each collection to find "SERVER_NAME" to achieve. However, if it contains a collection of other named "SERVER_NAME" The value (key name is not case-sensitive), when using Request ( "server_Name"), you will get the wrong results. All in all, as far as possible, direct access to the appropriate collection.

  three techniques: time-consuming operation in the property before Response.IsClientConnected

  Response.IsClientConnected used to observe whether the user is still connected to the server and are loading ASP page to create a useful way. If a user is disconnected or stop the download, we do not have to waste server resources to create the page, because the buffer zone will be discarded by IIS. Therefore, the calculation of those who need a lot of time or resources for the use of more pages, it is worth checking each stage in the Tour who has been off-line:

... ... Code to create first part of the page
If Response.IsClientConnected Then
End If
... ... Code to create next part of page

  four skills: Optimizing ASP operation of ADO

  face usually made, the data constitute the actual contents of the WEB site. Therefore, the optimization of ADO code to operate in order to speed up the implementation of ASP, very useful:
  a. only to select the desired rows: ADO recordset when opened, unless the need for access to all out, otherwise, should not automatically use table name (that is, SELECT *). Use a separate column will be reduced by means sent to the server or removed from the server the amount of data. Even need to use all the column names alone will get the best out of each performance, because the servers do not have to explain the column's name.

  b. the use of stored procedures as much as possible. Stored procedure is pre-compiled procedure, contains a good implementation plan is ready, so faster than the implementation of SQL statements.

  c. use appropriate cursor and lock mode. If all of the work done to focus only read data from the record and displays on the screen, then use the default forward only, read-only recordset. ADO lock used to protect the records and the details of the work the less the higher the performance of the implementation.

  d. the use of object variable. When ergodic recordset when a positive way to improve performance is to use the object variable to a member of the collection. For example:

While Not RsGc.EOF
Response.Write "Project Name:" & RsGc ( "GcMC") & "(project code:" & RsGc ( "GcCode") & ")

  can be rewritten as the following code to accelerate the implementation of:

set GcMc = RsGc ( "GcMc")
set GcCode = RsGc ( "GcCode")
While Not rsGc.EOF Response.Write "Project Name:" & GcMc & "(project code:" & GcCode & ")

  code established a new object reference variables, so variables can be used instead of the actual object of the variables, which means that the script engine to reduce the work, because in the collection in the number of index less.

  five skills: Do not mix engine script

  We know, ASP pages can use VBScript, can also use JScript. However, in the same page at the same time the use of jscript and vbscript is not desirable. Because the server must be instantiated and try to cache the two (not one) script engine, which to some extent, the burden of an increase of the system. Therefore, from a performance consideration, and should not mix in the same page a number of script engine. (karry / Cool page)

Asp Optimization Articles

Can't Find What You're Looking For?

Rating: Not yet rated


No comments posted.