The first time to write ASP class, to achieve the function: the implementation of a phased statistical program, output statistics and so on.
Program code:
Class Ccclsprocesstimerecorder
"Program Author: Moon Starlight
' Author homepage: Http://www.5iya.com/blog
"' Http://www.kuozhanming.com
' ASP program code execution time Statistics class
Private Ccinti,ccintnoncetime,ccintdecimal
Private ccintstarttime,ccintendtime,ccintnow,ccintnonce
Private Ccstrinterval,ccstrevent,ccstrtime,ccstrstatisticlog,ccstrformatinterval
Private Ccarrevent,ccarrtime
Private Sub Class_Initialize
Ccstrinterval = "|" ' Default separator
Ccintdecimal = 4 ' decimal digits
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
For ccinti = 1 to UBound (ccarrevent)
Ccstrstatisticlog = Ccstrstatisticlog & Ccarrevent (Ccinti) & ":" & Ccarrtime (Ccinti) & "s" & CCSTRF Ormatinterval
Next
Ccstrstatisticlog = ccstrstatisticlog & "--------------------------------------" & Ccstrformatinterval
Ccstrstatisticlog = ccstrstatisticlog & "total:" & FormatNumber (Ccintendtime-ccintstarttime,ccintdecimal, True,false,true) & "s"
Statistic = Ccstrstatisticlog
Else
statistic = "No record"
End If
End Function
Public Function Nonce
Ccintnoncetime = FormatNumber (timer-ccintnonce,ccintdecimal,true,false,true)
Ccintnonce = Timer
Nonce = Ccintnoncetime
End Function
Public Function Total
Total = FormatNumber (timer-ccintstarttime,ccintdecimal,true,false,true)
End Function
End Class