Results 1 to 3 of 3

Thread: Weird Timer

  1. #1
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Question Weird Timer

    I've a a few lines of code like this:
    MarkTime(t);
    Simba Code:
    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

  2. #2
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

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

  3. #3
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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