Improved ASP string processing performance

Source: Internet
Author: User
Abstract: Most Active Server Pages (ASP) applications use string connections to create HTML-formatted data that is presented to users. This article compares several methods for creating this HTML data stream. In specific cases, some methods are superior to other methods in terms of performance. This document assumes that you have some ASP and Visual Basic programming knowledge.
Directory
Introduction
ASP design
String connection
Quick Solution
StringBuilder
Built-in method
Test
Result
Summary
Introduction
When compiling an ASP page, the developer actually creates a formatted text stream and writes it to the Web client through the Response object provided by ASP. There are multiple ways to create this text stream, and the method you choose will have a great impact on the performance and scalability of Web applications. Many times, when I helped customers optimize the performance of their Web applications, I found that one of the more effective methods is to change the way HTML streams are created. This article will introduce several common technologies and test their impact on the performance of a simple ASP page.
ASP design
Many ASP developers follow good software engineering principles and try to modularize their code as much as possible. This design usually uses some include files that contain functions that are formatted and generated for specific discontinuous parts of the page. The string output of these functions (usually HTML table code) can be combined to create a complete page. Some developers have improved this method by moving these HTML functions to the Visual Basic COM component to take full advantage of the additional performance provided by compiled code.
Although this design method is good, the method used to create strings that comprise these discontinuous HTML code components will have a great impact on the performance and scalability of the Web site, whether the actual operation is performed in the ASP inclusion file or in the Visual Basic COM component.
String connection
See the following code snippet of the WriteHTML function. The parameter named Data is just a string array that contains some Data to be formatted as a table structure (for example, Data returned from the database ).
Function WriteHTML (Data)
Dim nRep
For nRep = 0 to 99
SHTML = sHTML & vbcrlf _
& "<TR> <TD>" & (nRep + 1) & "</TD> <TD> "_
& Data (0, nRep) & "</TD> <TD> "_
& Data (1, nRep) & "</TD> <TD> "_
& Data (2, nRep) & "</TD> <TD> "_
& Data (3, nRep) & "</TD> <TD> "_
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.