第一次寫ASP類,實(shí)現(xiàn)功能:分段統(tǒng)計(jì)程序執(zhí)行時(shí)間,輸出統(tǒng)計(jì)表等.
復(fù)制代碼 代碼如下:
Class ccClsProcessTimeRecorder
'程序作者:明月星光
'作者主頁:http://www.5iya.com/blog
'http://www.kuozhanming.com
'ASP程序代碼執(zhí)行時(shí)間統(tǒng)計(jì)類
Private ccInti,ccIntNonceTime,ccIntDecimal
Private ccIntStartTime,ccIntEndTime,ccIntNow,ccIntNonce
Private ccStrInterval,ccStrEvent,ccStrTime,ccStrStatisticLog,ccStrFormatInterval
Private ccArrEvent,ccArrTime
Private Sub Class_Initialize
ccStrInterval = "|" '默認(rèn)分隔符
ccIntDecimal = 4 '小數(shù)點(diǎn)后位數(shù)
ccStrEvent = ""
ccStrTime = ""
ccStrFormatInterval = "<br />" & vbCrLf
ccIntStartTime = Timer
ccIntNow = ccIntStartTime
ccIntNonce = ccIntStartTime
End Sub
Public Sub Record(ccStrEventName)
ccStrEvent = ccStrEvent & ccStrInterval & Replace(ccStrEventName,ccStrInterval,"")
ccStrTime = ccStrTime & ccStrInterval & FormatNumber(Timer-ccIntNow,ccIntDecimal,True,False,True)
ccIntNow = Timer
End Sub
Public Property Let Format(ccStrFormatType)
If LCase(Trim(ccStrFormatType)) = "html" Then
ccStrFormatInterval = "<br />" & vbCrLf
Else
ccStrFormatInterval = vbCrLf
End If
End Property
Public Function Statistic
If InStr(ccStrEvent,ccStrInterval) > 0 Then
ccIntEndTime = Timer
ccArrEvent = Split(ccStrEvent,ccStrInterval)
ccArrTime = Split(ccStrTime,ccStrInterval)
ccStrStatisticLog = ccStrStatisticLog & "Process Time Record" & ccStrFormatInterval
ccStrStatisticLog = ccStrStatisticLog & "--------------------------------------" & ccStrFormatInterval