Page 6 of 6 FirstFirst ... 456
Results 51 to 52 of 52

Thread: Gettickcount and the rest...

  1. #51

    Gettickcount and the rest...

    strange that it should work on some but not others....well timegettime works atleast and Queryperformancecounter no doubt works well.

    Code:
    Start:=gettickcount;
    sleep(1);
    sleep(1);
    sleep(1);
    sleep(1);
    sleep(1);
    sleep(1);
    sleep(1);
    sleep(1);
    sleep(1);
    sleep(1);
    Theend:=Gettickcount;
    Label1.caption:='time elapsed: '+floattostr( (Theend-Start))+'ms.';
    My small test (obviously mmsystem in uses). With timebeginperiod(1) 40 ms elaspses (4ms accuracy with sleep). Without it, the time that elapses is 156ms. So in my case there certainly is a massive shift in accuracy when Timebeginperiod is set to 1.

    However, if I set only one sleep(1) you are correct the accuracy stays at 16ms. This doesn't make sense?

    EDIT:

    Gettickcount seems unreliable, it can measure 10 sleeps at 4ms accuracy but not 1 to any accuracy. So I use timegettime, and low and behold the above example using one sleep (not 10) comes back as 2 ms elapsed. Therefore sleep is indeed affected by timebeginperiod but Gettickcount is unreliable at returning the value of elapsed time,wrong after one sleep, nearer after 10.

    Code:
    Start:=timegettime;
    sleep(1);  (will give atleast 2ms accuracy)
    Theend:=timegettime;
    Label1.caption:='time elapsed: '+inttostr( (Theend-Start))+'ms.';
    The above code will prove that sleep can be accurate to 2ms. Use ten sleep(1) and ity will return 20ms. Please do confirm this for me on your end

    NOTE: IT MATTERS WHERE YOU PLACE TIMEBEGINPERIOD(1). IT SHOULD BE IN THE ONCREATE OF YOUR FORM. THE TIMEENDPERIOD(1) IN THE ONCLOSE.

    If you put it in the button click, the accuracy comes out as 15-16ms like before.

  2. #52

    Gettickcount and the rest...

    I always thought that historically a tick was equal to 20 ms (based on the first computer frequency),

    It's quite far now for me, maybe it's not the same "tick" :read:

Page 6 of 6 FirstFirst ... 456

Bookmarks

Posting Permissions

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