{$cfg_webname}
主页 > 外文翻译 > 计算机翻译 >

优化ASP串中处理性能

来源:56doc.com  资料编号:5D2611 资料等级:★★★★★ %E8%B5%84%E6%96%99%E7%BC%96%E5%8F%B7%EF%BC%9A5D2611
资料以网页介绍的为准,下载后不会有水印.资料仅供学习参考之用. 帮助
资料介绍
摘要: 大多数活跃的服务器页(ASP)应用依赖串联建立HTML 格式化的数据然后被用户使用。本文对各种创造HTML 数据流的方法进行了比较,其中有一些在特定的情况下有更好的性能。asp 和Visual Basic编程设计的方法被合理采用了。
绪论
开发者编写ASP 页,其实是在创造一串格式化正文通过ASP提供给网络客户。你能使用多中不同的方法创造该正文,但是你所选择的方法网络应用的性能和可测量性有很大影响。在帮助用户协调他们Web 应用性能的许多场合中,我已经发现主要的获胜因素是那个改变HTML数据流的方式。在本文,我将展示一些普通的技术并且测试他们对简单的asp页的性能的影响。
asp 设计
很多asp开发者已经遵循好的软件设计原则并且模块化他们的代码。这种设计通常采取用某一页的部分离散的功能模块组成新页的形式。线性输出由这些功能实现,通常是HTML代码表,然后能通过各种各样结合形式形成完整的一页。一些开发者已经更深入一步研究并且把这些HTML函数作为Visual Basic COM的组成部分,希望受益于额外的编译代码提供的执行性能。
虽然这是一个好的设计惯例,通过这种方法建立数据流对网络站点执行效率有较大影响。不管现实操作执行是从asp的包含文件还是Visual Basic COM 零部件。(毕业设计 )
数据串串联
考虑下列代码碎片取自WriteHTML函数。 命名数据的参数仅仅是一个数组包含一些需要被格式化成一个表结构的数据(数据从数据库返回, 例如)。
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>" _
         & Data( 4, nRep ) & "</TD><TD>" _
         & Data( 5, nRep ) & "</TD></TR>"
Next
WriteHTML = sHTML

Summary: Most Active Server Pages (ASP) applications rely on string concatenation to build HTML-formatted data that is then presented to users. This article contains a comparison of several ways to create this HTML data stream, some of which provide better performance than others for a given situation. A reasonable knowledge of asp and Visual Basic programming is assumed. (11 printed pages)
Contents
Introduction
asp Design
String Concatenation
The Quick and Easy Solution
The StringBuilder
The Built-in Method
Testing
Results
Conclusion
Introduction
When writing ASP pages, the developer is really just creating a stream of formatted text that is written to the Web client via the Response object provided by ASP. You can build this text stream in several different ways and the method you choose can have a large impact on both the performance and the scalability of the Web application. On numerous occasions in which I have helped customers with performance-tuning their Web applications, I have found that one of the major wins has come from changing the way that the HTML stream is created. In this article I will show a few of the common techniques and test what effect they have on the performance of a simple asp page.
asp Design
Many asp developers have followed good software engineering principles and modularized their code wherever possible. This design normally takes the form of a number of include files that contain functions modeling particular discrete sections of a page. The string outputs from these functions, usually HTML table code, can then be used in various combinations to build a complete page. Some developers have taken this a stage further and moved these HTML functions into Visual Basic COM components, hoping to benefit from the extra performance that compiled code can offer.
Although this is certainly a good design practice, the method used to build the strings that form these discrete HTML code components can have a large bearing on how well the Web site performs and scales—regardless of whether the actual operation is performed from within an asp include file or a Visual Basic COM component.
String Concatenation
Consider the following code fragment taken from a function called WriteHTML. The parameter named Data is simply an array of strings containing some data that needs to be formatted into a table structure (data returned from a database, for instance).
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>" _
             & Data( 4, nRep ) & "</TD><TD>" _
             & Data( 5, nRep ) & "</TD></TR>"
Next
全文13700字
推荐资料