What is the best choice for improving ASP performance (iii)

Source: Internet
Author: User
Performance


Conclusion

The first part of this article is important in the accumulation of many small things. To emphasize this, I set up a final test in which all of the actions we had tested before seemed indifferent but actually had bad effects. I have included many Response.Write declarations, turned off buffers, set the default language, removed the option Explicit reference, and initialized the error handle.

<%@ language=vbscript% >
<%
on Error Resume Next
FirstName = "John"
...
birthdate = "1/1/1950"
Response.Write ("< HTML >")
Response.Write ("< head >")
Resp Onse. Write ("< title >response test</title >")
Response.Write (" Response.Write ("& Lt Body > ")
Response.Write (" < H1 >response test

Response.Write (" < table > ")
Response.Write ("< tr >< TD >< B >first name:</b ></td >< td >" &_
"Firs Tname & "</td ></tr >")
...
Response.Write ("< tr >< TD >< B >birth date:</></td >< td >" &_
" Birthdate & "</td ></tr >")
Response.Write ("</table >")
Response.Write ("</bod Y > ")
Response.Write (" % >

/app2/final_1.asp Fragment

Base value = 5.57 Msec/page
Reaction time = 8.85 Msec/page
difference = +3.28 msec (58.9% Increase)

It may sound obvious, but understanding is more important, and that is, the code we place on the page can have an impact on performance. Small changes on the page can sometimes greatly increase the reaction time.

Rule Summary

* Avoid excessive use of inline ASP.
* Always concatenate consecutive Response.Write statements into a single statement.
* Never use wrapper functions around Response.Write to attach CRLF.
* If you must format the HTML output, attach the CRLF directly within the Response.Write statement.
* Always open buffers via server settings.
* As long as the use of moderation, the ASP annotation has little or no impact on performance.
* Set the default language configuration of the server to match the language used on the site.
* Do not set a language declaration unless you use a Non-default language.
* Option Explicit is always used in VBScript.
* Always close the session state at the level of the page or application, if not required.
* Use the Include file only when the code is shared between pages.
* On a page, if the code is to be used more than once, the code is marshaled into the function area.
* Move the variable declaration to the function scope when appropriate.
* Use the error handle only if it occurs outside of the test or control capability.
* Use context processing only if two or more operations are executed as a unit.

Now, in retrospect, there are many issues that can serve as a universal approach:

* Avoid redundancy-do not set the properties that are already set in the default state.
* Limit the number of function calls.
* Narrow the scope of the code.

In the second part of this article, we'll explore some in-depth questions about ADO and COM objects.

>>>>> to Be Continued <<<<<




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.