Can anyone help me with this....

Results 1 to 5 of 5

Thread: Can anyone help me with this....

  1. #1
    Paul Hesketh Guest

    Default Can anyone help me with this....

    I&#039;ve written a search engine that searches a database on SQL server.<BR><BR>I would like to display the time it took to pull out the results (like does).How can I do this in VB/ Javascript?<BR><BR>Ideally the resulting display would be:<BR><BR>YOUR SEARCH TOOK 0.84 SECONDS<BR><BR>Thanks in advance!!

  2. #2
    Eddie Campbell Guest

    Default Easy

    &#060;% StartTime = Time()<BR>&#039; Run your Sql here<BR>EndTime = Time()<BR>ElapsedTime = DateDiff("s",StartTime, EndTime)<BR>Response.Write "Your search took " & ElapsedTime & " seconds"<BR>%&#062;

  3. #3
    Paul Hesketh Guest

    Default Not quite that easy..

    It works, but only displays the time to the nearest second.<BR><BR>In my case it either says "0" or "1" - is it possible to display a more exact measurement of time? (i.e 0.?? of a second?)

  4. #4
    Join Date
    Dec 1969

    Default RE: Not quite that easy..

    I keep this in an include file :<BR><BR>&#060;SCRIPT LANGUAGE=JScript RUNAT=Server&#062;<BR>function y2k(number) {<BR> return (number &#060; 1000) ? number + 1900 : number;<BR> }<BR>function milliDif() {<BR> var d = new Date();<BR> return d.getTime()<BR> }<BR> <BR>function elapsedtime(parm1)<BR>{<BR> var elapsedsecs = 0<BR> var elapsedmins = 0<BR> <BR> elapsedsecs=Math.floor(parm1/1000)<BR> parm1=parm1%1000<BR> <BR> elapsedmins=Math.floor(elapsedsecs/60)<BR> elapsedsecs=elapsedsecs%60<BR> <BR> <BR>elapsedtime=""+elapsedmins + " min"<BR>if(elapsedmins!=1)<BR> elapsedtime=elapsedtime+"s "<BR> <BR>elapsedtime = elapsedtime+" " + elapsedsecs + " sec"<BR>if(elapsedsecs!=1)<BR> elapsedtime=elapsedtime+"s "<BR>if(parm1 &#060; 100){<BR> parm1 = "0" + parm1;<BR>}<BR>elapsedtime = elapsedtime+parm1+" ms"<BR> <BR> return elapsedtime;<BR>} <BR>&#060;/script&#062;<BR><BR>Put this at the top of my page :<BR><BR>&#060;%<BR>&#039;~~~~~~~~~~~~~~~~~~<BR>&# 039;timing only<BR>dim timeThen,timeNow,timeDiff<BR>timeThen = milliDif()<BR>%&#062;<BR><BR>Then this at the bottom of my page :<BR><BR>&#060;%<BR>timeNow = milliDif()<BR>timeDiff = timeNow-timeThen<BR>response.write elapsedtime(timeDiff)<BR>%&#062;<BR><BR>Script timing in an instant!<BR><BR>HTH<BR><BR>MikeD

  5. #5
    Eddie Campbell Guest

    Default Looks good.

    I don&#039;t think that VbScript can access milliseconds. I guess I just didn&#039;t read the original post closely enough :(

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts