现在的位置: 首页 > 综合 > 正文

Asp调用函数是否会影响性能?

2012年10月26日 ⁄ 综合 ⁄ 共 1071字 ⁄ 字号 评论关闭

刚才我做过一个测试,测试结果如下:
<%
starttime=timer
'===超级连接====================================
Function LinkTo(Strurl,Strtext,Strtype,Strid,Strclass,Strtitle)
If Len(Strtext)=0 Then
    Response.Write "参数错误!"
    Exit Function
End If
If Len(Strtype)=0 Then
    Strtype="location.href"
Else
    Strtype=Strtype&".open"
End If
If Len(Strtitle)<>0 Then
    Strtitle=" title="""&Strtitle&""""
Else
    Strtitle=" title="""&Strtext&""""
End If
If Len(Strurl)=0 Then Strurl="#"
If Len(Strid)<>0 Then Strid=" id="""&Strid&""""
If Len(Strclass)<>0 Then Strclass=" class="""&Strclass&""""
LinkTo = "<a"&Strid&Strclass&Strtitle&" href=""#"">"&Strtext&"</a>"
End Function
For i=0 To 2000
If i>=2000 Then Exit For

Response.Write LinkTo ("?show=best/"& BoardID &ExtName&"","精华文章","","","","")
Next
endtime=timer
Response.Write ("<br>")& vbCrlf
Response.Write (endtime-starttime)*1000
%>
该测试,运行时间大约为46毫秒

<%
starttime=timer
For i=0 To 2000
If i>=2000 Then Exit For
Response.Write "<a href='?show=best/"& BoardID &ExtName&"'>精华文章</a>"
Next
endtime=timer
Response.Write ("<br>")& vbCrlf
Response.Write (endtime-starttime)*1000
%>
该测试,运行时间大约为15毫秒

如上两个测试分别都是在本机进行的,每个循环分别都是2000次,结果一目了然,最后的结论就是:Asp调用函数会影响程序的性能。

抱歉!评论已关闭.