![]() |
|
|
VBScript Timer functionThe 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. <% 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. Site developed by Michael Wall - Web Design Belfast N.Ireland. |
|