Improving string handling performance in ASP applications

Source: Internet
Author: User
Tags html form
Improving string handling performance in ASP applications
James Musson
Developer Services, Microsoft UK
March 2003
Apply to:
microsoft® Active Server pages®
Microsoft Visual basic®
Summary: Most Active Server Pages (ASP) applications use string concatenation to create HTML-formatted data that is presented to the user. This article compares several methods for creating this HTML data stream, and in certain cases some methods are superior to other methods in performance. This article assumes that you already have some knowledge of ASP and visual Basic programming.
Directory
Brief introduction
ASP Design
string concatenation
Quick Solution
StringBuilder
Built-in methods
Test
Results
Summary
Brief introduction
When writing an ASP page, the developer actually creates a formatted text stream that is written to the Web client through the Response object provided by the ASP. There are a number of ways to create this text stream, and the method you choose will have a significant impact on the performance and scalability of your WEB application. Many times, when I helped clients optimize the performance of their WEB applications, it was found that one of the more effective ways to change the way HTML streams were created. This article will introduce several common techniques and test their impact on the performance of a simple ASP page.
ASP Design
Many ASP developers follow good software engineering principles and modularize their code as much as possible. This design typically uses a number of include files that contain functions that are formatted for a particular discontinuous part of the page. The string output of these functions, usually the HTML form code, creates a complete page from a variety of combinations. Some developers have improved this approach by moving these HTML functions into Visual Basic COM components, hoping to take full advantage of the extra performance that has been provided by compiled code.
Although this design approach is good, the method used to create strings that make up these discrete HTML code components will have a significant impact on the performance and scalability of the Web site, regardless of whether the actual operation is performed in an ASP include file or in a Visual Basic COM component.
string concatenation
Take a look at the code snippet for the following writehtml function. The parameter named data is just an array of strings that contain some data to be formatted as a table structure (for example, data returned from a 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>" _
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.