ASP/VBScript Timer Class

Ever need to time your functions in ASP? Here's a quick little Timer class and a test function. To be as accurate as possible, we'll store the time in a separate variable and destroy the class "before" writing the output.

Ever need to time your functions in ASP? Here's a quick little Timer class and a test function. To be as accurate as possible, we'll store the time in a separate variable and destroy the class "before" writing the output.

<%

Class clsTimer
Private m_StartTimer
Private Sub Class_Initialize()
m_StartTimer = Timer
End Sub
Public Function GetElapsedTime()
GetElapsedTime = timer-m_StartTimer
end Function
End Class

Sub Test()

Dim nCnt
Dim sSeconds
Dim oTimer

Set oTimer = New clsTimer

For nCnt = 1 to 100
response.write "stuff"
Next

sSeconds = oTimer.GetElapsedTime
Set oTimer = Nothing
response.write "<br><br>Time Elapsed: " & sSeconds

End Sub

Call Test()

%>


Submission Date:  9/23/2005 2:50:35 PM
Submitted By:  Robbe Morris
My Home Page:  http://www.robbemorris.com

By Robbe Morris   Popularity  (829 Views)
Picture
Biography - Robbe Morris
Robbe has been a Microsoft MVP in C# since 2004. He is also the co-founder of NullSkull.com which provides .NET articles, book reviews, software reviews, and software download and purchase advice.  Robbe also loves to scuba dive and go deep sea fishing in the Florida Keys or off the coast of Daytona Beach. Microsoft MVP
Here's my most recent course on Pluralsight. I think it has some interesting insight on IT professional job interviews and using words in your resume to influence the questions you'll be asked. Resumes, Job Seeking, and Interviews in context.