28 Tips for improving ASP performance and appearance 7-18 (from Ms)

Source: Internet
Author: User
Tags iis
Tip 7: Encapsulate code in a COM object
If you have a lot of VBScript or JScript, you can often move your code to a compiled COM object, which can improve performance. The compiled code usually runs faster than the interpreted code. Compiled COM objects can access other COM objects through "early bound", which is a more efficient way to invoke COM objects than "late binding" used by the script.
There are some advantages to encapsulating code in COM objects (in addition to performance): COM objects facilitate separating presentation logic from business logic.
COM objects can ensure that code is reused.
Many developers find that code written in VB, C + +, or Visual J + + is easier to debug than ASP.
COM objects also have drawbacks, including initial development time and the need for different programming techniques. Note that encapsulating a small number of ASPs can cause performance degradation without performance improvements. This situation typically occurs when a small amount of ASP code is encapsulated into a COM object. In this case, the overhead of creating and invoking COM objects exceeds the benefits of compiled code. You should experiment repeatedly to determine what ASP scripts and COM object code combinations produce the best performance. Note that there is a significant improvement in scripting and ADO performance in Windows 2000/iis 5.0 compared to Microsoft Windows Nt®4.0/iis 4.0. Therefore, with the introduction of IIS 5.0, the compilation code has a lower performance advantage than the ASP code.
For a detailed discussion of the advantages and disadvantages of using COM in ASP, see ASP Component Guidelines and programming distributed applications with and Microsoft Visual Basic 6.0. If you are deploying COM components, it is particularly important to test them at a load. In fact, all of the ASP applications should be tested for load.
Tip 8: Get the resources later and release the resources earlier.
Here is a small tip for your reference. In general, it is best to obtain resources later and release resources earlier. This applies to COM objects as well as file handles and other resources.
This optimization method is mainly used for ADO connection and recordset. When you are finished using a recordset, say, after displaying a table and its data, you should release it immediately, rather than wait until the page ends. Setting the VBScript variable to nothing is the best practice. Do not let the Recordset go beyond the scope. Also, to release any associated Command or Connection objects (do not forget to call Close () until you set the recordset or connection to = Nothing.) This shortens the time that the database must prepare resources for you and frees the database to connect to the connection pool as soon as possible.
Tip 9: Process performance in exchange for reliability
Both ASP and mts/com+ have configuration options that allow you to balance reliability and performance. When you build and deploy your application, you should know how to balance the performance of both.
ASP Options
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.