Timing ASP Scripts

Click here for a larger image.

Environment: ASP .NET, ASP


This article describes a simple function that gets the duration time call of your ASP scripts. It's very useful to find the time elapsed between two points in your ASP scripts (for example, a DB calls script).

How to Use the Program

First, you must include the following JavaScript functions in your ASP script:

function y2k(number)
   return (number < 1000) ? number + 1900 : number;
function milliDif()
   var d = new Date();
      return d.getTime()

function elapsedpretty(parm1)
  var elapsedsecs = 0
  var elapsedmins = 0



elapsedpretty=elapsedmins + " minute"

elapsedpretty = elapsedpretty+" " + elapsedsecs+" second"

elapsedpretty = elapsedpretty+ " "+parm1+" millisecond"

  return elapsedpretty;

After that, just start your time counter with this line:

  '[start section to be evaluated]
  timeThen = milliDif()

Your ASP time-evaluated code must be between these two calls:

  'here some time consuming script code (like db calls,
  'for example)
  for i=1 to 2000000
    i  = i+1

And, finish the time counter with this code:

  '[end section to be evaluated]
  timeNow = milliDif()
  elapsed =timeNow-timeThen
  msg     ="Process time in ms: " & elapsed & _
  response.write msg


Download demo project - 1 Kb


  • ok

    Posted by mayursolanki_007 on 08/03/2006 08:42am


Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • By providing developers with the right tools to detect, understand, and fix problems early, your business can simplify software development, shorten development lifecycles, and improve the quality of software code. The end result is increased innovation, secure applications, and a faster time to market — all at a lower cost.

  • Lenovo recommends Windows 8 Pro. "I dropped my laptop getting out of the taxi." This probably sounds familiar to most IT professionals. If your employees are traveling, you know their devices are in for a rough go. Whether it's a trip to the conference room or a convention out of town, any time equipment leaves a user's desk it is at risk of being put into harm's way. Stay connected at all times, whether at the office or on the go, with agile, durable, and flexible devices like the Lenovo® …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date