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

  • Anthony Christie, the Chief Marketing Officer for Level Communications, is responsible for customer experience, worldwide marketing and product management. In this informative asset, he shares his insights into why a private network connection to cloud-bases applications is the right decision for your enterprise. Download now to find out more.

  • Enterprises are increasingly looking to platform as a service (PaaS) to lower their costs and speed their time to market for new applications. Developing, deploying, and managing applications in the cloud eliminates the time and expense of managing a physical infrastructure to support them. PaaS offerings must deliver additional long-term benefits, such as a lower total cost of ownership (TCO), rapid scalability, and ease of integration, all while providing robust security and availability. This report …

Most Popular Programming Stories

More for Developers

RSS Feeds

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