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

  • U.S. companies are desperately trying to recruit and hire skilled software engineers and developers, but there's simply not enough quality talent to go around. In response, companies often resort to inferior solutions -- hiring substandard developers and engineers, recruiting talent on a part-time or temporary basis, poaching people from competitors, or burdening an already stressed IT staff for more of their labor. Fortunately, there's a better solution. Read this white paper to learn the business value of …

  • On-demand Event Event Date: September 23, 2015 The cloud is not just about a runtime platform for your projects – now, you can do your development in the cloud, too. Check out this webcast to learn how the cloud improves your development experience and team collaboration. Join Dana Singleterry, Principal Product Manager for Oracle Dev Tools, as he discusses how to simplify every aspect of the development lifecycle, including requirements gathering, version management, code reviews, build automation, and …

Most Popular Programming Stories

More for Developers

RSS Feeds

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