Program | statistics | executive
ASP program code execution time statistic class
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
' 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
Class Properties:
1.Format
Output with HTML wrapping label
-html: Output HTML newline label and text line break (default)
-text: Output text line breaks only
Class method:
1.Record ("Code Name")
Counts the time since the last call to the record method to the present (the first call when the statistic Declaration class is at the time of the call), and finally the output in the statistic
Class functions: (Instant return information)
1.Nonce
The output from the last call to the Nonce function to the current time (the first call when the statistics declaration class up to the call time)
2.Total
Output declaration class up to now total time
3.Statistic
Output all record statistics and total program time
Instance code:
Dim objrecord,i,k,j,x
Set objrecord = New Ccclsprocesstimerecorder
Objrecord.format = "html"
For i = 1 to 100000
x = 2 + 2
Next
Call Objrecord.record ("addition")
For j = 1 to 100000
x = 2 * 2
Next
Call Objrecord.record ("multiplication")
For k = 1 to 100000
x = 2 ^ 2
Next
Call Objrecord.record ("square root")
Response.Write objrecord.statistic
Output:
Process Time Record
--------------------------------------
Addition: 0.0625 s
Multiplication: 0.0469 s
Radical: 0.1094 S