SRL Archive - OSR Help

Weird Timer


riwu

2012-10-07 02:19:05

I've a a few lines of code like this:
MarkTime(t);
if WaitFunc(@IsMoving,0,RandomRange(1100,1400)) then
begin
writeln(TimeFromMark(t));
IsMoving calculates pixel shift in 500 ms (in its 'root' function, simply a 'Wait(T)', where T is 500 in this case). And we are all dealing with integers here (so no rounding issues), so the only possible results i can get would be 500, 1000, 1500, or maybe very slightly more than these values if the system took a few ms to execute the functions.

Quite unexpectedly, i'm getting values like:
998
998
999
998
999
499
1014
1014
999
1498
1497


How is it possible to end up with anything less than 500? or slightly less than 1000/1500?

Also if anyone can answer this too..> http://villavu.com/forum/showthread.php?t=90792

masterBB

2012-10-07 07:44:48

wait isn't a perfect function. It wait in steps of x, so exact times are not possible.

riwu

2012-10-07 10:29:34

From: masterBB
wait isn't a perfect function. It wait in steps of x, so exact times are not possible.

Alright thanks. I always thought that wait() would, at the minimum be precise up to 1 ms. Seems like i've to give more leeway when it comes to timing :p