Results 1 to 4 of 4

Thread: Fastest timer component for Delphi

  1. #1

    Fastest timer component for Delphi

    Which is the best timer component for Delphi? The standard TTimer component isn't really fast and precise.

    I used to use Carlos Barbosa Threaded Timer, it has a resolution of 1 millisecond:

    http://www.carlosb.com/

  2. #2

    Fastest timer component for Delphi

    Welcome to the forums.

    With regards to your problem, I can't recommend a component but I can recommend a method of attaining high resolution timings.

    [pascal]
    var
    F,S,E: Int64;//Frequency / Start / End
    begin
    QueryPerformanceFrequency(F);
    QueryPerformanceCounter(S);
    Sleep(1000);//Do something interesting here rather than just go to sleep
    QueryPerformanceCounter(E);
    Label1.Caption:='Frequency = '+IntToStr(F);
    Label2.Caption:='Start = '+IntToStr(S);
    Label3.Caption:='End = '+IntToStr(E);
    Label4.Caption:='End - Start = '+IntToStr(E-S);
    Label5.Caption:='Elapsed Time = '+FloatToStr((E-S)/F);[/pascal]

    Just dump this code into a TButton.OnClick event a make sure you've got some labels on the form to get an idea of what's going on. It's pretty straightforward anyway. The sleep is just for demonstration purposes. If you are wondering why it doesn't return a value of exactly 1 (It should be around 0.99...) for the elapsed time, that is because Sleep is not accurate enough to sleep for exactly one second, not because the measurements are incorrect. This is the highest resolution timing i'm aware of on Windows based PCs. It does require a Pentium equivalent or higher to work but I'd say 95% of PCs are capable nowadays anyway.
    Isometric game development blog http://isoenginedev.blogspot.com/

  3. #3

    Fastest timer component for Delphi

    That's cool thanks!

  4. #4

    Fastest timer component for Delphi

    Well, at the end I found this code which does the trick quite well:
    http://www.swissdelphicenter.ch/torr...ode.php?id=216

    I measured the FPS and is very precise; although it can't go faster than 60fps, that's ok because the animation looks smooth.

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
  •