Library code snippets

Determine execution time in ASP

This is a very simple and neat script that allows you to determine the time (in Milli seconds) required to execute the code in an ASP page.

<script language=jscript runat=server>
function GetTime()
{
   var d = new Date();
   return d.getTime();
}
</script>

<%
   Dim StartTime, EndTime
   StartTime = GetTime()
   ' Do some stuff
   EndTime = GetTime()
   
   Response.Write "Process took: " & Cstr(EndTime - StartTime) & " MilliSeconds."
%>

Comments

  1. 05 Jan 2005 at 13:04

    You will get a type mismatch error if you Dim GetTime. It's a function, not a variable.

  2. 17 Sep 2002 at 07:05
    You can also use the Timer() method and avoid the switch from JS to VBS...

    dim StartTime : StartTime = Timer()


    ... CODE GOES HERE ...

    Response.write(Timer() - StartTime)
  3. 01 Jan 1999 at 00:00

    This thread is for discussions of Determine execution time in ASP.

Leave a comment

Sign in or Join us (it's free).

 Lio_889

We'd love to hear what you think! Submit ideas or give us feedback