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.

  • Moving from an on-premises environment to Office 365 does not remove the need to plan for disruptions or reduce the business risk requirements for protecting email services. If anything, some risks increase with a move to the cloud. Read how to ease the transition every business faces if considering or already migrating to cloud email. This white paper discusses: Setting expectations when migrating to Office 365 Understanding the implications of relying solely on Exchange Online security Necessary archiving …

Most Popular Programming Stories

More for Developers

RSS Feeds

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