网络编程
位置:首页>> 网络编程>> Asp编程>> asp什么情况下用响应缓冲会提高运行速度?

asp什么情况下用响应缓冲会提高运行速度?

  发布时间:2010-07-14 21:02:00 

标签:缓冲,速度,asp

什么情况下用响应缓冲会提高运行速度?

例1、脚本引擎与 HTML 之间的切换频繁,对响应流写操作太多,导致性能下降:

<table>
<% For Each fld in rs.Fields %>
<th><% = fld.Name %></th>
<%
Next 
While Not rs.EOF
%>
<tr>
<% For Each fld in rs.Fields %>
<td><% = fld.Value %></td>
<% Next 
</tr>
<% rs.MoveNext 
Wend %>
</table>

    例2、由于所有的代码包含在一个 VBScript 块内,每一行对响应流有一次写操作,效率更高:

<table>
<%
For each fld in rs.Fields
Response.Write (?<th>? & fld.Name & ?</th>? & vbCrLf)
Next
While Not rs.EOF
Response.Write (?<tr>?)
For Each fld in rs.Fields %>
Response.Write(?<td>? & fld.Value & ?</td>? & vbCrLf)
Next
Response.Write ?</tr>?
Wend
%>
</table>


结论:尽可能地多用 Response.Write 调用来代替捆绑紧密的内嵌表达式。

 

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com