Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Timer?


Message #1 by "Owen Mortensen" <ojm@a...> on Wed, 30 May 2001 14:23:45 -0700
Are there timer functions that will return me elapsed time in milliseconds?

I need to time some code to see where the bottleneck is.



TEA,

Owen



Message #2 by "Ken Schaefer" <ken@a...> on Thu, 31 May 2001 13:45:40 +1000
http://www.learnasp.com/learn/speedtimer.asp



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

----- Original Message -----

From: "Owen Mortensen" <ojm@a...>

To: "ASP Web HowTo" <asp_web_howto@p...>

Sent: Thursday, May 31, 2001 7:23 AM

Subject: [asp_web_howto] Timer?





: Are there timer functions that will return me elapsed time in

milliseconds?

: I need to time some code to see where the bottleneck is.

:





Message #3 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Thu, 31 May 2001 09:40:15 +0100
Use the setTimeout method of the browser



From MSDN:



setTimeout Method



------------------------------------------------------------------------

----

----



Evaluates an expression after a specified number of milliseconds has

elapsed.



Syntax



iTimerID =3D window.setTimeout(vCode, iMilliSeconds, sLanguage)

Parameters



vCode Required. Variant that specifies the function pointer or string 

that

indicates the code to be executed when the specified interval has 

elapsed.

iMilliSeconds Required. Integer that specifies the number of 

milliseconds.

sLanguage Required. String that specifies one of the following values:

JScript Language is JScript.

VBScript Language is VBScript.

JavaScript Language is JavaScript.





Return Value



Integer. Returns an identifier that cancels the evaluation with the

clearTimeout method.



Remarks



In versions earlier than Microsoft=AE Internet Explorer 5, the first 

argument

of setTimeout must be a string. Evaluation of the string is deferred 

until

the specified interval elapses.



As of Internet Explorer 5, the first argument of setTimeout can be a 

string

or a function pointer.



The specified expression or function is evaluated once. For repeated

evaluation, use the setInterval or setInterval method.



Example



The following example uses the setTimeout method to evaluate a simple

expression after one second has elapsed.



window.setTimeout("alert('Hello, world')", 1000);

The following example uses the setTimeout method to evaluate a slightly 

more

complex expression after one second has elapsed.



var sMsg =3D "Hello, world";

window.setTimeout("alert(" + sMsg + ")", 1000);

This example uses the setTimeout method to hide a INPUT type=3Dbutton 

object

after three seconds. If the user clicks the Count Down button and then

counts to three, the Now You See Me button disappears.



<SCRIPT>

function fnHide(oToHide){

   window.setTimeout("fnHide2(" + oToHide.id + ")", 3000);

}

function fnHide2(sID){

   var o =3D eval(sID);

   o.style.display=3D"none";

}

</SCRIPT>

<INPUT TYPE=3Dbutton VALUE=3D"Now you see me ..."

    ID=3D"oHideButton" onclick=3D"fnHide(this)">

This example uses a function pointer to pass the data. In this case, 

the

data is stored in a global variable because it cannot be passed 

directly. In

the preceding example, the ID of the button is passed as a parameter to 

the

function invoked by the setTimeout method. This is possible only when a

string is passed as the first argument.



<SCRIPT>

var g_oToHide =3D null;



function fnHide(oToHide){

    g_oToHide =3D oToHide;

    window.setTimeout(fnHide2, 3000);

}

function fnHide2(sID){

    if (g_oToHide) {

       g_oToHide.style.display=3D"none";

    }

}

</SCRIPT>

<INPUT TYPE=3Dbutton VALUE=3D"Now you see me ..." ID=3D"oHideButton"

    onclick=3D"fnHide(this)">



-----Original Message-----

From: Owen Mortensen [mailto:ojm@a...]

Sent: 30 May 2001 22:24

To: ASP Web HowTo

Subject: [asp_web_howto] Timer?





Are there timer functions that will return me elapsed time in 

milliseconds?

I need to time some code to see where the bottleneck is.



TEA,

Owen





Message #4 by "Morgan, Rob" <Rob.Morgan@o...> on Thu, 31 May 2001 07:07:19 -0400
Does timer work for ya?





Dim StartTime, EndTime

StartTime =3D Timer

For I =3D 1 To 10000

Next

EndTime =3D Timer

TimeIt =3D EndTime - StartTime

response.write timeit





-----Original Message-----

From: Owen Mortensen [mailto:ojm@a...]

Sent: Wednesday, May 30, 2001 5:24 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Timer?





Are there timer functions that will return me elapsed time in 

milliseconds?

I need to time some code to see where the bottleneck is.



TEA,

Owen




  Return to Index