You are not logged in.
Pages: 1
Guys,
Can you help with making time based uuid(timestamp)?
Very quick comes to my mind curtime:=FloatToStr(Now);
But maybe there is something more precise? As result some Int64 will be good.
Maybe mORMot could help there?
Last edited by Greg0r (2020-03-02 08:43:17)
Offline
Check UnixMSTimeUTC() function to retrieve the time as such.
See https://synopse.info/files/html/api-1.1 … XMSTIMEUTC
And check TSynUniqueIdentifier/TSynUniqueIdentifierGenerator which purpose is to create 64-bit UUID even spread on over several systems (up to 65536 generation points).
See https://synopse.info/files/html/api-1.1 … IDENTIFIER
Online
@ab, thx
I'm after lecture of https://www.thedelphigeek.com/2007/10/c … urate.html
I did not imagined before how not accurate are std functions.
Solutions from your framework looks good.
Can you provide shortest simplest usage of your functions to get current time in XXXXXXXXXXXXX int64?
UnixMSTimeUTC() function and TSynUniqueIdentifier/TSynUniqueIdentifierGenerator
Last edited by Greg0r (2020-03-02 10:13:27)
Offline
Just call UnixMSTimeUTC().
Under Windows, it calls GetSystemTimeAsFileTime() which has true ms resolution.
Under Linux, it will call the fast clock_gettime(CLOCK_REALTIME_COARSE) if available.
See https://docs.microsoft.com/en-us/window … ime-stamps for some official information from Microsoft.
Online
Thank you
Offline
After more research, I found http://www.windowstimestamp.com/description
It appears that GetSystemTimeAsFileTime() doesn't have true ms resolution, but only follows the HW timer interrupt, which may be around 10-16 ms.
On Windows 8+, UnixMSTimeUTC() will use https://docs.microsoft.com/en-us/window … asfiletime which is slightly slower, but has true ms resolution.
Please check https://synopse.info/fossil/info/9a8e9b23ad
Online
Offline
Pages: 1