Small example, but it is more complicated. Compile with fpc -k"-framework Cocoa" machtimeexample.pas
But you need to transate the ticks to time with mach_timebase_info(), which I never used, (yet) but this code is the proper timer.
{$mode objfpc}
{$modeswitch objectivec1}
program MachTimeExample;
uses
ctypes, MacOSAll, CocoaAll;
var
timebase: mach_timebase_info_data_t;
startTime, endTime, elapsedNano: UInt64;
begin
// Initialize the timebase info - necessary to convert ticks to nanoseconds
mach_timebase_info(@timebase);
// Get the start time
startTime := mach_absolute_time();
// Do some work you want to measure
// For example, a small delay
NSProcessInfo.processInfo.sleepForTimeInterval(0.5); // Sleep for 0.5 seconds
// Get the end time
endTime := mach_absolute_time();
// Calculate elapsed time in nanoseconds
elapsedNano := (endTime - startTime) * UInt64(timebase.numer) div UInt64(timebase.denom);
writeln('Start time: ', startTime, ' ticks');
writeln('End time: ', endTime, ' ticks');
writeln('Elapsed: ', elapsedNano, ' nanoseconds');
writeln(' ', elapsedNano / 1000000:0:3, ' milliseconds');
end.
This one is tested, the rest I have to find out....
.....Like you...

My Apple mini is just a toy for these kind of things. I am no expert in that sense.