On macOS, GetSecs no longer returns absolute time!

Under macOS, GetSecs used to return absolute time, mach_absolutetime() which is seconds since some date like January 1, 1904. This was useful for aligning data collected on multiple computers. I just ran GetSecs on the latest Psychtoolbox under macOS and am very surprised to get a time corresponding to about 40 hours, very likely the time that my computer was last booted. This is a serious reduction of functionality. Can we go back to absolute time, mach_absolutetime(), as the documentation still says?
p.s. I wrote the original version of GetSecs in the 1980s.

See if GetSecs('AllClocks') provides what you need

1 Like

This behavior has been a while. I guess it is due to the change in mach_absolute_time() by Apple? If so, we will need to update the documentation.

Unfortunately it breaks when you try to align time from multiple computers. But in my opinion, this is a good change in terms of precision. If GetSecs=0 means Jan 1, 1904, its precision for now is at the order of 10e-7 (still enough for most of our purpose, but barely). While GetSecs is about 40 hours, the precision is at the order of 10e-11.

1 Like

GetSecs() never returned absolute time on OSX with PTB-3. mach_absolute_time() never did either. Just as GetSecs(), the zero point of mach_absolute_time() is unspecified according to docs. In practice it seems to be time since system boot, but this is not to be relied on, just as the help of GetSecs clearly states. Atm. only GetSecs on Linux returns time since 1.1.1973 iirc, but that is only for historical reasons, and at some point, if i ever find the time for it, i may change that to time since boot / CLOCK_MONOTONIC, because as Xiangrui notes, it provides better absolute precision for various reasons. Also because most system times related to input and output operate in a time-base related to bootup.

We have GetSecs(‘AllClocks’) for purpose of syncing/mapping time across machines/against something like UTC.

1 Like