足球游戏_中国足彩网¥体育资讯$

ASP:页面输出太多会严重影响web程序的性能
来源:易贤网 阅读:714 次 日期:2014-09-19 10:52:17
温馨提示:易贤网小编为您整理了“ASP:页面输出太多会严重影响web程序的性能”,方便广大网友查阅!

数据量增加的很快,最近发现它的性能非常差,每次打开都需要十几秒,甚至几十秒,因为我

的程序分页用的是我自己的分页程序:

难道这个分页程序有问题,但是其他地方用到它没有感觉到慢呀,我没事就琢磨他,到网上查资料,结果没有具体查到说到我的那个分页程序性能差的相关资料,后来我发现我的程序中的页导航用的是数字导航方法,而且所有的页导航的数字全都输出来了,一共一千多页,能不能使这个地方慢呢?我决定测试一下,所以,我就只让他输出前200页的导航链接,结果1秒钟就刷出来了。这我才恍然大悟,原来是输出内容太多导致的。以前遇到性能问题都会去想数据库操作,从来没有想到其他地方会不会有问题,或很少想其他地方。其实页面输出的数据量对性能也是有很大影响的,所以我们一定要养成良好的程序书写习惯,力求简单。

后来我对程序进行了优化,优化分两个步骤,第一个步骤我不将所有的导航都输出来,只输出前200多页,后面再加一个文本框用于导航。

同时我对每个链接进行了简化,原来每个上面都有很长的链接,至此我将链接放到了javascript函数中,然后再导航数字上只加上一个onclick事件。这样又可以减少很多输出数据。结果性能非常好。

原来的代码片断:

<font color="#008080" size="2">当前<font color=ff0000>

<%=tCurPage%></font>页 共<font color=ff0000>

<%=tpagecount%></font>页

<br><% if tTotalCount>0 then

for i=1 to tPagecount

%><a href='<%=request.servervariables("Path_Info")%>

?page=<%=i%>&browserSize=<%=browserSize%>

&t_count=<%=tTotalCount%>&order_field=<%=tOrderField%>

&order_dir=<%=tOrderDirection%>&oType=<%=oType%>

&oOP=<%=oOP%>&oKey=<%=FilterParam4(oKey)%>

&page_size=<%=tPageSize%><%=add_Option%>'><%=i%></a>

<% if browserSize=1 then

if i=20 or i=36 then response.write " "

end if

if i=fCou then

exit for

end if

response.write ""

next %>

<%dim allStr

if tpagecount>fCou then

for i=fCou+1 to tpagecount

if browserSize=0 then

m=(i=74 or i=107 or (i>107 and ((i-107) mod 27)=0))

else

m=(i=94 or i=130 or (i>130 and ((i-130) mod 35)=0))

end if

allStr=allStr & "<a href='"&request.servervariables("Path_Info")&"?

page="&i&"&browserSize="&browserSize&"&t_count=" & tTotalCount &

"&order_field=" & tOrderField & "&order_dir=" & tOrderDirection & "&

oType=" & oType & "&oOP=" & oOP & "&oKey=" & FilterParam4

(oKey) & "&page_size=" & tPageSize & add_Option &

"'>"

allStr=allStr & i

allStr=allStr & "</a>"

if not m then allStr=allStr & " "

if m then allStr=allStr & "<br>"

if browserSize=1 then

if i=58 or i=71 then allStr=allStr & " "

end if

if i=106 then allStr=allStr & " "

next%>

<script language=javascript>

var allStr;

allStr="<%=allStr%>";

</script><a href="#" title="显示中国足彩网…" id=seemore

>

<font color=ff0000>∨</font></a><span id=morePage></span>

<%end if %>

<% end if %> </font>

更改后的代码片断:

< script language="javascript">

function mP(curPage)

{

try{

if(!curPage)return false;

var patInt=/^d+$/;

if(!patInt.test(curPage)) return false;

if(parseInt(curPage)<=0) return false;

self.location='<%=request.servervariables("Path_Info")%>?

page=' + curPage+ '&browserSize=<%=browserSize%>

&t_count=<%=tTotalCount%>&order_field=<%=tOrderField%>

&order_dir=<%=tOrderDirection%>&oType=<%=oType%>

&oOP=<%=oOP%>&oKey=<%=FilterParam4(oKey)%>

&page_size=<%=tPageSize%><%=add_Option%>';

}

catch(e) {

window.status=e.description

return false;

}

}

< /script>

<font color="#008080" size="2">当前<font color=ff0000>

<%=tCurPage%></font>页 共<font color=ff0000>

<%=tpagecount%></font>页

<br><% if tTotalCount>0 then

for i=1 to tPagecount

%><span ><%=i%></span>

<% if browserSize=1 then

if i=20 or i=36 then response.write " "

end if

if i=fCou then

exit for

end if

response.write ""

next

dim allStr

if tpagecount>fCou then

showPageCount=tpagecount

if showPageCount>260 then showPageCount=260

for i=fCou+1 to showPageCount

if browserSize=0 then

m=(i=74 or i=107 or (i>107 and ((i-107) mod 27)=0))

else

m=(i=94 or i=130 or (i>130 and ((i-130) mod 35)=0))

end if

allStr=allStr & "<span >GO</span>"%><a href="#" title="显示中国足彩网…"

id=seemore ><font color=ff0000>∨</font></a>

<span id=morePage style="display:none"><%=allStr%></span>

<%end if

end if

%> </font>

中国足彩网信息请查看IT技术专栏

中国足彩网信息请查看网络编程
下一篇:ASP通用模板类
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!
关于我们 | 联系我们 | 人才招聘 | 网站声明 | 网站帮助 | 非正式的简要咨询 | 简要咨询须知 | 加入群交流 | 手机站点 | 投诉建议
工业和信息化部备案号:滇ICP备2023014141号-1 足球游戏_中国足彩网¥体育资讯$ 滇公网安备53010202001879号 人力资源服务许可证:(云)人服证字(2023)第0102001523号
云南网警备案专用图标
联系电话:0871-65317125(9:00—18:00) 获取招聘考试信息及咨询关注公众号:hfpxwx
咨询QQ:526150442(9:00—18:00)版权所有:易贤网
云南网警报警专用图标