Recent

Author Topic: How to get time in miliseconds?  (Read 4211 times)

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 370
How to get time in miliseconds?
« on: December 05, 2018, 12:41:34 pm »
How to get time in miliseconds on Mac? With 1 ms accuracy.

On Windows I call TimeGetTime() with TimeBeginPeriod(1) / TimeEndPeriod(1).


dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: How to get time in miliseconds?
« Reply #1 on: December 05, 2018, 01:19:21 pm »
cross platform, do you want to time something or really get the actual time ?


Code: Pascal  [Select][+][-]
  1. var Tick, Tock : qword;
  2.  
  3. Tick := gettickcount64();
  4. Something()
  5. Tock := gettickcount64();
  6. debugln('Something took '+ inttostr(Tock-Tick) + 'mS');

If you want the real time, call now(), there are a number of functions that  will turn a TDateTime into what ever format you want.
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • My goal: build my own game engine using Lazarus
Re: How to get time in miliseconds?
« Reply #2 on: December 05, 2018, 01:37:55 pm »
Several options are available, read more:
http://forum.lazarus.freepascal.org/index.php/topic,41430.msg287441.html#msg287441

FYI, GetTickCount64 isn't very precise.

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 370
Re: How to get time in miliseconds?
« Reply #3 on: December 05, 2018, 02:17:19 pm »
Thanks! I will check these variants.

 

TinyPortal © 2005-2018