WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Time - Timer and Date Functions
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

TimeDelays and Tight Loops

Keywords: 	  TimeDelays and Tight Loops

Question:

I am running WinBatch Version 2000D on a Petium 3, 1.13 GHZ machine. I want to run a tight loop, but not too tight. However, it seems that whenever I add a time delay it greatly slows things down. I think that any time delay smaller than 0.1 seconds equals 0.05 seconds in Winbatch. Therefore, even a very small time delay of 0.0001 equals 0.05 instead. On my computer, by adding any time delay at all or any conditional If-Then statement it slowed down the loops per 5 seconds down from about 18,000 loops down to 60 loops. Of course at 18,000 loops it was using 100% of the cycles on the computer, but at 60 loops it was using less than 5%. I would like something in between these two extremes. Any ideas? Thanks!

Here is my test code:

C = 0
LoopyStart = TimeYmdHms()

:Loopy
C = C+1

ResetTime = TimeYmdHms()
RDiff = TimeDiffSecs(LoopyStart,ResetTime) 
If RDiff < -5 then goto GlobalX

;Rem out the timedelay line and it speeds 
;up the loop about 300 times
timedelay(0.0001)

Goto Loopy

:GlobalX
message('Done',c)
exit 

Answer:

Ive heard that javascript can't actually schedule any tighter than 55 ms because of the way the system clock works. perhaps wbt has a similar problem?

For a real short timedelay try

Yield
or maybe Yield(10)

or something like they. A Yield is a *very* short timedelay.

Alternatively you may be interested in changing the process scheduling priority.


Article ID:   W15306
File Created: 2002:09:05:13:51:18
Last Updated: 2002:09:05:13:51:18