' get timer before task begins:
starttime = Timer()
' do some task, e.g.:
Do While z < 350000
z = z + 1
Loop
' get timer after task completes:
endtime = Timer()
' display results:
Response.Write "The task completed in " & endtime-starttime & " s"
Response.Write " (" & (endtime-starttime)*1000 & " milliseconds)."
' set number of seconds:
numSeconds = 5
' set counter:
counter = 0
' get starttime:
starttime = now()
' set endtime to some time more than numSeconds in the future:
endtime = dateadd("n", numseconds + 1, starttime)
' loop until numSeconds have passed, resetting endtime each loop:
Do Until DateDiff("s", starttime, endtime) = numSeconds
endtime = Now()
counter = counter + 1
Loop
' display results:
Response.Write "In " & numSeconds & " seconds, the task completed " & counter & " times."
Response.Write "<br>(Average time per loop: "
Response.Write FormatNumber(numSeconds*1000/counter,0,-1,0,-1) & " milliseconds.)"
Source: http://classicasp.aspfaq.com/general/how-do-i-time-my-asp-code.html
Originally Posted on July 30, 2013
Last Updated on October 26, 2015
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.