[Lazarus] How to program with time in milliseconds?
Michael Van Canneyt
michael at freepascal.org
Thu May 15 09:51:58 CEST 2014
On Thu, 15 May 2014, Michael Schnell wrote:
> --- sorry, previous mail seems to be digested by some scrambler ---
>
> On 05/14/2014 09:44 PM, Michael Van Canneyt wrote:
>>
>> Hopefully you got rid of the fpgettimeofday, or else the component is
>> no better than using Now() :-)
>
> Michael,
>
> Even though I of course was aware of this, I did used fpgettimeofday to
> implement TTimer with the "ActiveNoGui" WidgetType, as I did not find
> something more appropriate in the RTL.
There is nothing cross platform. GetTickCount64 comes closest.
>
> Of course I could try to directly read the X86's "Performance counter"
> register, but there were discussions if same would by reliable usable in CPU
> / OS combinations. I also could try to use vDSO in Linux archs (is that
> always available ?)
Only in recent versions, and I am not sure it is always enabled,
however I have not studied the subject in depth.
>
> Of course in the end I need something that works for any CPU and OS.
There is nothing. EpikTimer pretends to fill this gap, but it does not.
Don't get me wrong: I have nothing against the epiktimer, but it is
presented as some super cross-platform solution (or so I perceive it).
Which is simply not correct. Unless you use the i386 version
of the compiler, it is not better than using now().
>
> At best, fpgettimeofday itself should be improved (maybe using "Performance
> counter" register if the Arch allows for or vDSO if the OS allows for).
FYI: fpgettimeofday is a direct kernel call, there is nothing to improve.
get_clock() and friends could be used, but we need to add this to the (base)unix units first.
Now it is only available in the linux unit. I seem to recall that Marco Van De Voort was going
to look into this, but memory is somewhat fuzzy on this subject...
Michael.
More information about the Lazarus
mailing list