I have been using Win32 timers for years now, but was surprised to find that the fastest I can get a a timer routine to increment a long var is 64 times a second. This proved to be the case for both Win98 on a 500MHZ system and XP on a 2.8GHZ.


; LN:8 t1.interval=1000
mov eax,1
mov [_ArgSafe0],eax
mov eax,1000
invoke SetTimer,[!OBMain],[_ArgSafe0],eax,NULL
; LN:9 t2.interval=10
mov eax,2
mov [_ArgSafe0],eax
mov eax,10
invoke SetTimer,[!OBMain],[_ArgSafe0],eax,NULL
.
.
.
; LN:19 t2.timer
t2_timer:
; LN:20 incr x
inc
; LN:21 end event
ret
; LN:23 t1.timer
t1_timer:
; LN:24 incr y
inc
; LN:25 ts=str(y)+" "+str(x)
.
.
.
Posted on 2005-12-23 20:26:47 by mikes

timers created with CreateWaitableTimer do a better job, an interval of 4 ms should be no problem.
Posted on 2005-12-24 03:00:50 by japheth
timer functions from WINMM are good too(e.g.timeSetEvent) :P
Posted on 2005-12-24 09:09:44 by k3Eahn
Usually, SetTimer is a low-resolution timer. This means it is not accurate (precise). Don't use it for high-performance apps. It was desgined for static windows gui and stuff.

timeSetEvent is a very high-resolution timer, but it must be set up properly. You must use timeBeginPeriod first if you want a resolution of 1ms, though. I suggest you use it if you want an accurate timer.

Usually, the speed of the processor doesn't really matter for timers.
Posted on 2005-12-27 06:39:17 by The Grey Beast