Codefixer - ASP tutorials, resources and software
ASP.NET 3.5/2.0 Hosting – Click Here
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Saturday 10 May
MembersPro PayPal - ASP Membership software

DiscountASP.NET – ASP.NET 3.5/2.0 Hosting


ASP Partner ASP Partner ASP Partner more partners...

VBScript Timer function

The VBScript Timer function returns the number of seconds that have elapsed since 12:00 AM (midnight).

Below is an example function from the Microsoft website. The following code snippet example uses the Timer function to determine the time it takes to iterate a For...Next loop N number of times:

In the code below we call our function TimeIt and pass in the parameter 10000 i.e. to loop ten thousand times. The Timer function will return the number of seconds to the millisecond since 12.00 AM midnight and assign to our variable StartTime. We then enter the loop and execute the loop from 1 to 10000. After that the Timer function will return the number of seconds since 12.00 AM midnight to our variable EndTime. To get the time the loop took to execute we simply subtract EndTime from StartTime. Our function returns the time it takes and then we assign that to our new variable TimeitTakes.

<%
Function TimeIt(N)
Dim StartTime, EndTime
StartTime = Timer
For I = 1 To N
Next
EndTime = Timer
TimeIt = EndTime - StartTime
End Function

TimeitTakes=TimeIt(10000)
Response.write TimeitTakes
%>

Here's another example - Timing the retrieval of database records using the Timer Function





If you have any code snippets to share with full credit given then send an email to Codesnippets - You'll receive full credit and a link back to your site.

ASP.NET 3.5/2.0 Web Hosting: 3 Months FREE – Click Here!




About | Contact | Advertise | Feedback | Hire Us | Link

Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.

Do you intend to move to ASP.NET or have you already?
Yes will do
Have done
ASP does fine
Not a priority


Directory Software