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