Asp調用函數是否會影響效能?

來源:互聯網
上載者:User

剛才我做過一個測試,測試結果如下:
<%
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調用函數會影響程式的效能。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.