I have written two timer functions to mimic the Windows QueryPerformanceCounter and QueryPerformanceFrequency on Linux.
Can somebody verify they work as advertised, correctness?
It works on my machines.....type of code....(Raspberries and WIN64/LIN64
{$ifdef unix}
function QueryPerformanceFrequency(out value:int64):boolean;inline;
begin
Result := true;
Value := 1000000000;
end;
function QueryPerformanceCounter(out value:int64):int64;inline;
var
t:Timespec;
begin
result:=clock_gettime(CLOCK_THREAD_CPUTIME_ID{or CLOCK_MONOTONIC?},@t);
Value :=t.tv_nsec;
end;
{$endif}
Also, what kind of clock should I use? See code.
I needed it to make am_profiler.pas from my previous post cross-platform.
I realize not all cpu's have a clock, so I need to add an exception(or three).