Recent

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

Igor Kokarev

  • Jr. Member
  • **
  • Posts: 75
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: 571
    • 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 1.8, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

Handoko

  • Hero Member
  • *****
  • Posts: 3041
  • 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

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